json学习之二:JSONObject对象运用

json学习之二:JSONObject对象使用为了使用JSONObject对象,我们要引入net.sf.json包。import net.sf.json.

json学习之二:JSONObject对象使用
为了使用JSONObject对象,我们要引入"net.sf.json"包。

import net.sf.json.JSONArray;import net.sf.json.JSONObject;public class JsonTest {public static void main(String[] args) throws Exception {//创建JSONObject对象 通过put(Object key,Object value)方法添加元素JSONObject json = new JSONObject();json.put("version", "1.1.0");json.put("host", "maps.google.com");json.put("home_mobile_country_code", 460);// 国家代码json.put("home_mobile_network_code", 0);// 移动运营商代码json.put("radio_type", "gsm");json.put("request_address", true);json.put("address_language", "zh_CN");JSONArray jsoncells = new JSONArray();JSONObject jsoncell = new JSONObject();jsoncell.put("mobile_country_code", 460);// 国家代码,mccjsoncell.put("mobile_network_code", 0);// 移动运营商代码,mncjsoncell.put("location_area_code", 42246);// 位置区域代码,lac LAC 42246jsoncell.put("cell_id", 21379917);// 移动基站id CID 21379917jsoncell.put("timing_advance",5555);//将JSONObject对象添加到JSONArray中jsoncells.add(jsoncell);//将JSONArray对象添加到JSONObject中json.put("cell_towers", jsoncells);System.out.println(json.toString());    }}

API参考:
http://json-lib.sourceforge.net/apidocs/jdk15/index.html 1 楼 zljerityzljerity 2012-08-01   JSONObject.fromObject(line)这段代码的意思是什么,它得到的是一个什么东东?