I have a json list like this from PHP:
$Json = '[{"test":"1", "message":"try it"},
{"test":"2", "message":"try it"}, {"test":"3", "message":"try it"} ...]';
$final = [ 'error' => '1', 'json' => json_encode($Json)];
die(json_encode($final));
From Android i can show the result like this:
JsonParser jsonParser = new JsonParser();
JsonObject res = (JsonObject) jsonParser.parse(new Gson().toJson(response.body()));
Log.w("Return", response.body().toString());
All works fine until now, but when i try to make a new Json Object
from the returned results, i get this error message:
com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonObject
Here what i did:
JsonObject json = (JsonObject) jsonParser.parse(new Gson().toJson(res.get("json").toString()));
Log.w("JSON", json.toString());
Any fix please ?