Reputation: 21
I am trying to use some of the json conversion methods available in net.sf.json.JSONArray and net.sf.json.JSONObject but it appears these objects are not compatible with (Androids) org.json.JSONArray and org.json.JSONObject objects. Essentially what I am looking for is an efficient and easy way to transform a valid JSON String into Java objects like Arrays. The net.sf.json package objects appear to have such conversion methods.
My question is - Is net.sf.json.JSONArray compatible with org.json.JSONArray and if so how can these objects be used? Attempting to cast from one to the other gets me nowhere.
JSONArray jsonArray = new JSONArray();
jsonArray = orgJSONArray;
jsonArray = (JSONArray)orgJSONArray;
If I can't use net.sf.json with org.json objects, in the realm of Android what is the best and most efficient way to convert a valid JSON string to a Java Array object.
Upvotes: 2
Views: 2715
Reputation: 47699
By definition net.sf.json.JSONObject
is not "compatible" with org.json.JSONObject
unless one is a subclass of the other. Even if the two classes were to have word-for-word identical definitions, the different package names would make them totally different and incompatible classes.
Upvotes: 2