{ name: '机房/1号楼1层1-01', data: [0,0,0,0,0,0,0,0,0] }有数据请问用怎么用json串拼成前面格式?
答案:1 悬赏:30 手机版
解决时间 2021-02-09 10:20
- 提问者网友:动次大次蹦擦擦
- 2021-02-09 00:22
{ name: '机房/1号楼1层1-01', data: [0,0,0,0,0,0,0,0,0] }有数据请问用怎么用json串拼成前面格式?
最佳答案
- 五星知识达人网友:鸠书
- 2021-02-09 01:41
定义两个属性
String name;
int[] data;追问给在详细点吗?比如怎么向json串中添加数据,我刚初学,请见谅追答public class Stu {
private String name;
public int[] data;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int[] getData() {
return data;
}
public void setData(int[] data) {
this.data = data;
}
}
public class Test {
public static void main(String[] args) throws Exception {
Stu stu = new Stu();
stu.setName("12345");
stu.setData(new int[]{0,0,0,0,0,0,0});
System.out.println(JSONObject.fromObject(stu));
}
}
将就着看吧
包: json-lib
String name;
int[] data;追问给在详细点吗?比如怎么向json串中添加数据,我刚初学,请见谅追答public class Stu {
private String name;
public int[] data;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int[] getData() {
return data;
}
public void setData(int[] data) {
this.data = data;
}
}
public class Test {
public static void main(String[] args) throws Exception {
Stu stu = new Stu();
stu.setName("12345");
stu.setData(new int[]{0,0,0,0,0,0,0});
System.out.println(JSONObject.fromObject(stu));
}
}
将就着看吧
包: json-lib
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯