Use Gson from Google. The first method is for you to retrieve the data you have received in JSON format, and the other is to convert the object and send as JSON. You can use anytype of object. You can create a class that have all those parameters and send/receive with an instance of that class. You only need to convert from JSON to string, something is easily done with toString()
import com.google.gson.Gson;
public class JSONParser
{
private static Gson gson = new Gson();
public static Data jsonToData(String json)
{
return gson.fromJson(json, Data.class);
}
/**
* Converts the object to JSON
* @param obj object from type Object
* @return String of JSON format
*/
public static String objectToJson(Object obj)
{
Gson writer = new Gson();
return writer.toJson(obj);
}
}