{“name”:”jhon”,”condition”:[“relation”:”and/or”,”sex”:”###”,
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 09:35:30
{“name”:”jhon”,”condition”:[“relation”:”and/or”,”sex”:”###”,”age”:”###”] } 怎么写
这样格式的JSON怎么才能写出来?
jinwenf:这个字符串写到JAVA里面的时候会报错,意思是在[]中不能有“:”.
lazysunboy:你的方法也有些问题,最后生成出来的是“{"condition":{"sex":"main","age":"23","relation":"and"},"name":"john"}”这个样子,我需要的是[]里面是键值对,不要{}
我现在也不知道这个JSON串到底对不对了...
kejiaweiren:也就是说其实我的这个格式是错误的,不是JSON的格式吧,我生成的也是{}包裹着的.
这样格式的JSON怎么才能写出来?
jinwenf:这个字符串写到JAVA里面的时候会报错,意思是在[]中不能有“:”.
lazysunboy:你的方法也有些问题,最后生成出来的是“{"condition":{"sex":"main","age":"23","relation":"and"},"name":"john"}”这个样子,我需要的是[]里面是键值对,不要{}
我现在也不知道这个JSON串到底对不对了...
kejiaweiren:也就是说其实我的这个格式是错误的,不是JSON的格式吧,我生成的也是{}包裹着的.
public class Test {
public static void main(String[] args) {
Map map = new HashMap();
map.put( "name","json" );
Map map2 = new HashMap();
map2.put("relation","and/or");
map2.put("sex","###");
map2.put("age","###");
map.put("condition",map2);
JSONObject jsonObject = JSONObject.fromObject( map );
System.out.println( jsonObject );
}
}
出来的是{"condition":{"sex":"###","age":"###","relation":"and/or"},"name":"json"}
这个是正确的
public static void main(String[] args) {
Map map = new HashMap();
map.put( "name","json" );
Map map2 = new HashMap();
map2.put("relation","and/or");
map2.put("sex","###");
map2.put("age","###");
map.put("condition",map2);
JSONObject jsonObject = JSONObject.fromObject( map );
System.out.println( jsonObject );
}
}
出来的是{"condition":{"sex":"###","age":"###","relation":"and/or"},"name":"json"}
这个是正确的
{“name”:”jhon”,”condition”:[“relation”:”and/or”,”sex”:”###”,
NAME AGE SEX BLOO
英语翻译1.the name or trade name and address or registered offic
Excuse me () what's your name and还是or
Print or Type Author's name and address:
Jhon does exercise three or four times对不对
求NAME SEX BIRTH BLOODTYPE汉语意思
the relation between congress and president
the relation between domestication and foreignization
英语翻译Fill in name and/or address on(or in)the bag if differen
SEX AND THE CITY怎么样
sex and power 翻译为什么?