Which one to use? JSONObject from org.json VS JsonObject from javax.json

后端 未结 4 1946
傲寒
傲寒 2020-12-28 12:45

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

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-28 13:20

    JSONObject, as mentioned, is provided by android's API. JsonObject is specifically used for Java EE development which is essentially for web applications and networking capabilities among other things.

    The reason Android does not prepackage JsonObject from Oracle Java EE package is because alot of the things javax can do, are not allowed within android like accessing the internet without permission. This means importing the entire jars files of javax would conflict with Android.

    If you plan to build your own backend with Java EE, I would highly suggest using JsonObject over JSONObject. On the other hand, if you know a prebuilt rest service or something similar that supports Android's JSON even better.

提交回复
热议问题