Name |
JSONObject JSON对象 |
||||||||||||||||||||||||||
Examples |
JSONObject json;
void setup() {
json = new JSONObject();
json.setInt(“id”, 0); json.setString(“species”, “Panthera leo”); json.setString(“name”, “Lion”);
saveJSONObject(json, “data/new.json”); }
// Sketch saves the following to a file called “new.json”: // { // “id”: 0, // “species”: “Panthera leo”, // “name”: “Lion” // } |
||||||||||||||||||||||||||
Description |
A JSONObject stores JSON data with multiple name/value pairs. Values can be numeric, Strings, booleans, other JSONObjects or JSONArrays, or null. JSONObject and JSONArray objects are quite similar and share most of the same methods; the primary difference is that the latter stores an array of JSON objects, while the former represents a single JSON object. JSON can be generated from scratch, dynamically, or using data from an existing file. JSON can also be output and saved to disk, as in the example above. JSONObject 存储具有多个名称/值对的 json 数据。数值可以是数字、字符串、布尔值、其他 JSONObjects 或 JSONArrays 或 null。JSONObject 和 JSONArray 对象非常相似, 并且共享大多数相同的方法;主要区别在于后者存储了一个 json 对象数组, 而前者则表示一个 json 对象。
可以从头开始、动态地或使用现有文件中的数据生成 json。json 也可以输出并保存到磁盘上, 如上面的示例中所示。 |
||||||||||||||||||||||||||
Methods |
|
||||||||||||||||||||||||||
Related |
JSONArray |
- 本文固定链接: http://iprocessing.cn/2017/07/19/jsonobject-json对象/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表