Android Developer 文档
https://developer.android.com/reference/org/json/package-summary.html
JSONObject
常用的JSON数据类型
A modifiable set of name/value mappings.
Names are unique, non-null strings.
Values may be any mix of JSONObjects, JSONArrays, Strings, Booleans, Integers, Longs, Doubles or NULL.
插入数据 : put
JSONObject put (String name,
double value)
Maps name to value, clobbering any existing name/value mapping with the same name.
JSONObject studentJSONObject = new JSONObject();
studentJSONObject.put("name", "Jason");
studentJSONObject.put("id", 20130001);
studentJSONObject.put("phone", "13579246810");
获取数据 : getString
org.json中有很多种get方法,如 get 、getBoolean 、getDouble 、getInt 、getJSONArray 、getJSONObject 、getLong
Returns the value mapped by name if it exists.
会进行强制类型转换
studentJSONObject = (JSONObject) args[0];
name = studentJSONObject.getString("name");
id = studentJSONObject.getInt("id");
phone = studentJSONObject.getString("phone");