What are the significant diffs between:
Most importantly are they interchangeable from client to Webservice? ie. can I send JSONObject to Webservice and have the Webservice believe the type is JsonObject (and vice versa)?
(JSONObject found in the json-20080701.jar of ACRA)
(JsonObject found in C:\glassfish4\glassfish\modules\javax.json.jar)
What are the significant diffs between
org.json.JSONObject
andjavax.json.JsonObject
?
javax.json.JsonObject
is included in Java EE 7javax.json.JsonObject
is immutableorg.json.JSONObject
has siginificantly more convenience methodsMost importantly are they interchangeable from client to Webservice? ie. can I send JSONObject to Webservice and have the Webservice believe the type is JsonObject (and vice versa)?
Of course this should work. It is not the class instance which gets transferred to the webservice, but the JSON data, which is generated from the class instance. On the other side, the JSON data can be parsed back into any kind of object.
Example:
If you have a simple class named Person:
public class Person {
private String name = "Hans";
private int age = 26;
}
This could be transformed into JSON similar to: {"name":"Hans", "age":25}
The generated JSON string is sent to the webservice.
Now, on the other end of your application, or in any other application, this JSON string can be parsed into any class, if you have an appropriate parser. You don't even need Java to parse it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With