forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONArray.xml
More file actions
66 lines (48 loc) · 1.31 KB
/
JSONArray.xml
File metadata and controls
66 lines (48 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>JSONArray</name>
<category>Data</category>
<subcategory>Composite</subcategory>
<type></type>
<example>
<image></image>
<code><![CDATA[
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"
// }
// ]
]]></code>
</example>
<description><![CDATA[
A <b>JSONArray</b> stores an array of JSON objects. <b>JSONArray</b>s 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.
]]></description>
<type>class</type>
</root>