Hello all in this article we are going to learn about JsonObject related. As we know that json object are used widely for getting, storing data and performing simple crud action on data.
In mostly enterprise level application. Due to maintenance of library , or some other reason we have to switch latest librarys, which are maintained by well company.
Now lets learn what are the difference in these librarys:
Storing of data: net.sf.json lib
Note : the put() method accepts all type value such as String,Int, char, JSONArray, JSONObject, String[] , list etc.
Storing of data: com.google.gson lib
Note:
1.Here two methods are there add() and addProperty()
add() methods only accepts JsonObject and JsonArray ,
addProperty() methods only stores primative data like string, int, char, boolean.
2.These methods do not store string[], Array list . to store these types we should convert it into either JsonArray , JSONObject or string.
3.JsonArray in both case are using add method.
The difference is it considers value in object form but in gson library it considers as JsonElement.
Fetching Data: net.sf.json
Note: there are several methods I have covered which are commonly used.
Fetching Data: com.google.gson library
Note:
1. Here optString, optInt , optBoolean optJSONObject , optJSONArray methods are not present.
2. If these methods requires then we have to implement it manually.
Thank You
Amarnath Mali
Helical IT Solutions
Best Open Source Business Intelligence Software Helical Insight is Here