zoukankan      html  css  js  c++  java
  • JSONObject.fromObject()

     

    在将前台传回的对象JSON集字串在后台转为对象集时老是出错,搜了很久没有解决方法,一查API,搞定。

    JSONObject.fromObjec()不能解析list中NULL值。

    当然,这个NULL值不是指JSON对象为NULL值,实际写没这么用的。这个NULL值是指 JSON字串中 对象的属性/方法不能为NULL值。JSONObject.fromObjec()会去调用正确的JSONObject工厂方法,而NULL值明显没有。

    fromObject

    public staticJSONObject fromObject(Object object)

    Creates a JSONObject.

    Inspects the object type to call the correct JSONObject factorymethod. Accepts JSON formatted strings, Maps, DynaBeans and JavaBeans.

    Parameters:

    object  -

    Throws:

    JSONException - if the object can not be converted to a properJSONObject.

    fromObject

    public staticJSONObject fromObject(Object object)

    创建JSONObject。

    检查对象类型以调用正确的JSONObject工厂方法。 接受JSON格式的字符串,Maps,DynaBeans和JavaBeans。

    参数:

    object  -

    抛出异常:

    JSONException - 如果对象无法转换为正确的JSONObject。

    所以说,要多看API!!!

  • 相关阅读:
    codeforces 985 F. Isomorphic Strings
    Educational Codeforces Round 44
    codeforces 979D
    ARC060 Digit Sum II
    Iroha and Haiku II
    Unhappy Hacking II
    Just h-index 2018湘潭邀请赛
    [HAOI2007]理想的正方形
    P1231 教辅的组成
    最小割数学形式
  • 原文地址:https://www.cnblogs.com/Sherlock-J/p/12926028.html
Copyright © 2011-2022 走看看