Hi in my project i need to create a JSONArray type with the GSON class
{
\"message\": [
\"msg 1\",
\"msg 2\",
\"msg 3\"
],
\"asec\": [
the class:
public class JsonStructure{
public String[] message;
public String[] asec;
}
using it:
JsonStructure json = new JsonStructure();
json.message = new String[]{"msg 1", "msg 2", "msg 3"};
json.asec = new String[]{"asec 1", "asec 2", "asec 3"};
Gson gson = new Gson();
String output = gson.toJson(json);
//convert from string
JsonStructure fromString = gson.fromJson(output, JsonStructure.class);
For more details on Google's gson please take a look at https://sites.google.com/site/gson/gson-user-guide