and following are the alternatives to be used. You don't. Java. Gson - First Application. The first field is deserialized to Java date type: second one does not respect it, so will be parsed by a default SimpleDateFormat object that has not milliseconds ("yyyy-MM-dd'T'HH:mm:ss'Z' is the parsing format) Gson: Directly convert String to JsonObject (no POJO) 447. Example attached Based on the javadoc for Gson 2.8.6. The key "test" in the myJSONString variable has a value of 100.00 In order to "DOUBLEFY" this value of 100.00, you call the parseDouble method from the Double class. Java Thread or Android HandlerThread: Java threads are one-time use only and die after executing its run method. So lets see how we can code for encoding part of the JSON object using JSONObject function. Gson is the main class for using Gson library. The above method helps you to convert an object of some class type to a JSON object without tampering any data types as we use ObjectMapper library. It's a very simple way to convert: import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; class Usuario { private String username; private String email; private Integer credits; private String twitter_username; public Add a comment | //from object to JSON Gson gson = new Gson(); gson.toJson(yourObject); // from JSON to object yourObject o = gson.fromJson(JSONString,yourObject.class); But if one just want to parse a JSON string and get some values, (OR create a JSON string from scratch to send over wire) just use JaveEE jar which contains JsonReader, JsonArray, JsonObject etc. JSON stands for JavaScript Object Notation.JSON is one of the widely used data-interchange format as it is a lightweight data-interchange format and language independent and it started to slowly replace the XML format. The problem is you're telling Gson you have an object of your type. Java Thread or Android HandlerThread: Java threads are one-time use only and die after executing its run method. Example 2. In my opinion, due to type erasure, the parser can't fetch the real type T at runtime. User user = new User(); Gson gson = new Gson(); Object request = gson.toJson(user); When I use this in another JSON builder that asks for an Object I get It can also be used to convert a JSON string to an equivalent Java object. Convert inner LinkedHashMaps back to proper objects public class Output { public int Keyname { get; set; } public Object outputvalue{ get; set; } //outvalue may be even a object collection } List