I am grabbing a string from a database that looks like this
[{"messageContent":"Good morning Christine! My name is Oso, it\u0027s
beary nice to meet you
:3","msgType":"MSG_TYPE_RECEIVED","statusCode":0,"timeString":"10:31"},
{"messageContent":"Good morning Christine! My name is Oso, it\u0027s
beary nice to meet you
:3","msgType":"MSG_TYPE_RECEIVED","statusCode":0,"timeString":"10:31"}
It began as an ArrayList but I had to convert it into a string to store in in the database.
I need to convert it back. I had was going to use this function but it doesn't seem to work.
public static ArrayList<ChatMessage> fromString(String value) {
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
return new Gson().fromJson(value, listType);
}
I get this error when I try to run the function.
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 3 path $[0]