io.InputStream is). Convert a stream of JSON text into object form. static. JSONObject.If an error occurs in the serialization, the return will be of format: JSON Generation Error:  Overrides To implement JSON in java using GSON we need to add an external JAR that can be downloaded from Here. GSON provides two useful methods and everything moven around these two methods. toJson() Convert Java object to JSON format fromJson() Convert JSON into Java object.