JSON与JAVA的数据转换--Map

2、Map
 Map map = new HashMap();       
map.put( "name", "json" );       
map.put( "bool", Boolean.TRUE );       
    
map.put( "int", new Integer(1) );       
map.put( "arr", new String[]{"a","b"} );       
map.put( "func", "function(i){ return this.arr[i]; }" );       
JSONObject json = JSONObject.fromObject( map );       
System.out.println( json );       
 //{"func":function(i){ return this.arr[i]; },"arr":["a","b"],"int":1,"name":"json","bool":true}    
 
Map map = new HashMap();     
 map.put( "name", "json" );     
 map.put( "bool", Boolean.TRUE );     
   
 map.put( "int", new Integer(1) );     
 map.put( "arr", new String[]{"a","b"} );     
 map.put( "func", "function(i){ return this.arr[i]; }" );     
 JSONObject json = JSONObject.fromObject( map );     
 System.out.println( json );     
 //{"func":function(i){ return this.arr[i]; },"arr":["a","b"],"int":1,"name":"json","bool":true} 

你可能感兴趣的:(xml,excel,json,related)