[英] Which one to use? JSONObject from org.json VS JsonObject from javax.json
This is my first post. As a budding Android developer, I read SO posts on a near daily basis on various topics, but for this question, I didn't find any help from Google or SO.
My research so far:
Searching for this question was harder than normal because the search engines don't seem to care about case-sensitivity, which is vital in this issue. Searching Google only gave me links to the classes themselves, old articles, or completely irrelevant articles. The closest I got was JSONArray vs JSONObject, and that is a completely different question. SO searching gave the same results. As far as I can tell, ALL pertinent posts on SO refer to JSONObject and not JsonObject.
I would have also posted a link to the Android reference page for JSONObject, but my rep as a newbie is too low.
History of problem(s): I was reading about Json encoding and decoding from the Oracle page, and I tried copying and pasting into my AndriodStudio IDE, which immediately produced an error, for which it did not suggest an import statement like it normally does. I have come to learn that means the class is not part of the built-in libraries.
The problem was that the code I pasted in used JsonObject (which comes from javax.json library) and not JSONObject (which comes from org.json library). When I noticed the difference in case between the Android page and the Oracle page, I altered my code from Json to JSON and immediately my IDE offered the org.json import statement.
Why is an Oracle made class not part of the default libraries when an external library is?
Is JSON the old, deprecated way and Json the new, proper way?
Are they functionally identical? If not, please provide examples?
Are some situations better for one and some better for the other?
ULTIMATELY, which should I use, and why (if not already covered)?
If, javax.json, where is the best (safest) place to download that library)?