admin 管理员组

文章数量: 1086019


2024年3月13日发(作者:linux 复制)

n(("sex"));

判断输出对象的类型

boolean isArray = y();

boolean isEmpty = y();

boolean isNullObject = Object();

n("是否数组:"+isArray+", 是否空:"+isEmpty+", 是否空为空对象:"+isNullObject);

把JSONArray添加到JSONObject中

/把JSONArray添加到JSONObject中

JSONArray jsonArray = new JSONArray();

(0, "张三");

(1, "123");

//开始添加

t("student", jsonArray);

n(json);

全部代码:

import ray;

import ject;

public class Json {

public static void main(String[] args) {

//创建JSONObject

JSONObject json = new JSONObject();

//添加属性

("username", "张三");

("password", "123");

//打印

n(json);

//增加属性

t("sex", "男");

("age", 18);

n(json);

//根据key返回

n(("sex"));

//判断输出对象的类型

boolean isArray = y();

boolean isEmpty = y();

boolean isNullObject = Object();

n("是否数组:"+isArray+", 是否空:"+isEmpty+", 是否空为空对象:"+isNullObject);

n("=====");

//把JSONArray添加到JSONObject中

JSONArray jsonArray = new JSONArray();

(0, "张三");

(1, "123");

//开始添加

t("student", jsonArray);

n(json);

}

}


本文标签: 对象 添加 属性 输出 类型