What are the significant differences between org.json.JSONObject and javax.json.JsonObject ?
javax.json.JsonObject included in Java EE 7javax.json.JsonObject is immutableorg.json.JSONObject has significantly more convenient methods
Most importantly, are they interchangeable with a client on Webservice? i.e. can I send a JSONObject to the Webservice and have a web service what type is JsonObject (and vice versa)?
Of course, this should work. This is not an instance of the class that is passed to the webservice, but JSON data that is generated from the instance of the class. On the other hand, JSON data can be parsed back to any object.
Example:
If you have a simple class called Person:
public class Person { private String name = "Hans"; private int age = 26; }
This can be converted to JSON, similar to: {"name":"Hans", "age":25}
The generated JSON string is sent to the webservice.
Now, at the other end of your application, or in any other application, this JSON string can be parsed in any class if you have the appropriate parser. You don't even need Java to parse it.
source share