1 回答

扬帆大鱼
TA贡献1799条经验 获得超9个赞
Map map = new HashMap();
map.put( "name", "json" );
map.put( "bool", Boolean.TRUE );
map.put( "int", new Integer(1) );
map.put( "array", new String[]{"a","b"} );
map.put( "func", "function(i){ return this.arr[i]; }" );
JSONObject jsonObject = JSONObject.fromObject( map );
try {
List<Object> arr = jsonObject.names();//获取名
Collection<Object> arra = jsonObject.values();//获取值
for(Object name:arr){
System.out.println(name.toString());
}
for(Object value:arra){
System.out.println(value.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
添加回答
举报
0/150
提交
取消