Name |
JSONArray JSON数组 |
||||||||||||||||||||||||||||||||||||
Examples |
String[] species = { “Capra hircus”, “Panthera pardus”, “Equus zebra” }; String[] names = { “Goat”, “Leopard”, “Zebra” };
JSONArray values;
void setup() {
values = new JSONArray();
for (int i = 0; i < species.length; i++) {
JSONObject animal = new JSONObject();
animal.setInt(“id”, i); animal.setString(“species”, species[i]); animal.setString(“name”, names[i]);
values.setJSONObject(i, animal); }
saveJSONArray(values, “data/new.json”); }
// Sketch saves the following to a file called “new.json”: // [ // { // “id”: 0, // “species”: “Capra hircus”, // “name”: “Goat” // }, // { // “id”: 1, // “species”: “Panthera pardus”, // “name”: “Leopard” // }, // { // “id”: 2, // “species”: “Equus zebra”, // “name”: “Zebra” // } // ] |
||||||||||||||||||||||||||||||||||||
Description |
A JSONArray stores an array of JSON objects. JSONArrays 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. JSONArray 存储一个 json 对象数组。JSONArrays 可以从头开始、动态地或使用现有文件中的数据生成。json 也可以输出并保存到磁盘上, 如上面的示例中所示。 |
||||||||||||||||||||||||||||||||||||
Methods |
|
||||||||||||||||||||||||||||||||||||
Constructor |
JSONArray() |
||||||||||||||||||||||||||||||||||||
Related |
JSONObject |
Updated on April 30, 2017 02:33:20pm EDT
- 本文固定链接: http://iprocessing.cn/2017/07/17/jsonarray-json数组/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表