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!!!

  • 相关阅读:
    MySQL decimal unsigned 更新负数不报错却为0
    centos 安装jdk
    CentOS7安装docker
    Cron 时间元素
    PHPStorm
    日志习惯
    HTTP幂等性
    navicat for mysql 10.1.7注册码
    localStorage、sessionStorages 使用
    FreePascal
  • 原文地址:https://www.cnblogs.com/Sherlock-J/p/12926028.html
Copyright © 2011-2022 走看看