Skip to content

Commit cfcf122

Browse files
committed
Added reference for all JSONArray get and set methods
1 parent 46d01c5 commit cfcf122

10 files changed

+230
-20
lines changed

content/api_en/JSONArray_getBoolean.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
// The following short JSON file called "data.json" is parsed
16+
// in the code below. It must be in the project's "data" folder.
17+
//
18+
// [ 32, 1.13, "grape", true ]
19+
20+
JSONArray json;
21+
22+
void setup() {
23+
24+
json = loadJSONArray("data.json");
25+
26+
int count = json.getInt(0);
27+
float weight = json.getFloat(1);
28+
String name = json.getString(2);
29+
boolean isFruit = json.getBoolean(3);
30+
31+
println(count + ", " + weight + ", " + name + ", " + isFruit);
32+
}
33+
34+
// Sketch prints:
35+
// 32, 1.13, grape, true
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Gets the boolean value associated with the specified index.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_getFloat.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
// The following short JSON file called "data.json" is parsed
16+
// in the code below. It must be in the project's "data" folder.
17+
//
18+
// [ 32, 1.13, "grape", true ]
19+
20+
JSONArray json;
21+
22+
void setup() {
23+
24+
json = loadJSONArray("data.json");
25+
26+
int count = json.getInt(0);
27+
float weight = json.getFloat(1);
28+
String name = json.getString(2);
29+
boolean isFruit = json.getBoolean(3);
30+
31+
println(count + ", " + weight + ", " + name + ", " + isFruit);
32+
}
33+
34+
// Sketch prints:
35+
// 32, 1.13, grape, true
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Gets the float value associated with the specified index.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_getInt.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
// The following short JSON file called "data.json" is parsed
16+
// in the code below. It must be in the project's "data" folder.
17+
//
18+
// [ 32, 1.13, "grape", true ]
19+
20+
JSONArray json;
21+
22+
void setup() {
23+
24+
json = loadJSONArray("data.json");
25+
26+
int count = json.getInt(0);
27+
float weight = json.getFloat(1);
28+
String name = json.getString(2);
29+
boolean isFruit = json.getBoolean(3);
30+
31+
println(count + ", " + weight + ", " + name + ", " + isFruit);
32+
}
33+
34+
// Sketch prints:
35+
// 32, 1.13, grape, true
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Gets the int value associated with the specified index.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_getIntArray.xml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,41 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
// The following short JSON file called "data.json" is parsed
16+
// in the code below. It must be in the project's "data" folder.
17+
//
18+
// [ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 ]
19+
20+
JSONArray json;
21+
22+
void setup() {
23+
24+
json = loadJSONArray("data.json");
25+
26+
int[] values = json.getIntArray();
27+
28+
println(values);
29+
}
30+
31+
// Sketch prints:
32+
// [0] 0
33+
// [1] 1
34+
// [2] 1
35+
// [3] 2
36+
// [4] 3
37+
// [5] 5
38+
// [6] 8
39+
// [7] 13
40+
// [8] 21
41+
// [9] 34
42+
// [10] 55
43+
// [11] 89
44+
// [12] 144
1645
]]></code>
1746
</example>
1847

1948
<description><![CDATA[
20-
To come...
49+
Returns the entire <b>JSONArray</b> as an array of ints. (All values in the array must be of the int type.)
2150
]]></description>
2251

2352
</root>

content/api_en/JSONArray_getString.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
// The following short JSON file called "data.json" is parsed
16+
// in the code below. It must be in the project's "data" folder.
17+
//
18+
// [ 32, 1.13, "grape", true ]
19+
20+
JSONArray json;
21+
22+
void setup() {
23+
24+
json = loadJSONArray("data.json");
25+
26+
int count = json.getInt(0);
27+
float weight = json.getFloat(1);
28+
String name = json.getString(2);
29+
boolean isFruit = json.getBoolean(3);
30+
31+
println(count + ", " + weight + ", " + name + ", " + isFruit);
32+
}
33+
34+
// Sketch prints:
35+
// 32, 1.13, grape, true
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Gets the String value associated with the specified index.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_getStringArray.xml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,33 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
// The following short JSON file called "data.json" is parsed
16+
// in the code below. It must be in the project's "data" folder.
17+
//
18+
// [ "sasquatch", "yeti", "jackalope", "unicorn", "centaur" ]
19+
20+
JSONArray json;
21+
22+
void setup() {
23+
24+
json = loadJSONArray("data.json");
25+
26+
String[] values = json.getStringArray();
27+
28+
println(values);
29+
}
30+
31+
// Sketch prints:
32+
// [0] "sasquatch"
33+
// [1] "yeti"
34+
// [2] "jackalope"
35+
// [3] "unicorn"
36+
// [4] "centaur"
1637
]]></code>
1738
</example>
1839

1940
<description><![CDATA[
20-
To come...
41+
Returns the entire <b>JSONArray</b> as an array of Strings. (All values in the array must be of the String type.)
2142
]]></description>
2243

2344
</root>

content/api_en/JSONArray_setBoolean.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
JSONArray json;
16+
17+
void setup() {
18+
19+
json = new JSONArray();
20+
21+
json.setInt(0, 32);
22+
json.setFloat(1, 1.13);
23+
json.setString(2, "grape");
24+
json.setBoolean(3, true);
25+
26+
println(json);
27+
}
28+
29+
// Sketch prints:
30+
// [
31+
// 32,
32+
// 1.1299999952316284,
33+
// "grape",
34+
// true
35+
// ]
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Inserts a new value into the <b>JSONArray</b> at the specified index position. If a value already exists in the specified position, the new value overwrites the old value. If the given index is greater than the length of the <b>JSONArray</b>, then null elements will be added as necessary to pad it out.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_setFloat.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
JSONArray json;
16+
17+
void setup() {
18+
19+
json = new JSONArray();
20+
21+
json.setInt(0, 32);
22+
json.setFloat(1, 1.13);
23+
json.setString(2, "grape");
24+
json.setBoolean(3, true);
25+
26+
println(json);
27+
}
28+
29+
// Sketch prints:
30+
// [
31+
// 32,
32+
// 1.1299999952316284,
33+
// "grape",
34+
// true
35+
// ]
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Inserts a new value into the <b>JSONArray</b> at the specified index position. If a value already exists in the specified position, the new value overwrites the old value. If the given index is greater than the length of the <b>JSONArray</b>, then null elements will be added as necessary to pad it out.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_setInt.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
JSONArray json;
16+
17+
void setup() {
18+
19+
json = new JSONArray();
20+
21+
json.setInt(0, 32);
22+
json.setFloat(1, 1.13);
23+
json.setString(2, "grape");
24+
json.setBoolean(3, true);
25+
26+
println(json);
27+
}
28+
29+
// Sketch prints:
30+
// [
31+
// 32,
32+
// 1.1299999952316284,
33+
// "grape",
34+
// true
35+
// ]
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Inserts a new value into the <b>JSONArray</b> at the specified index position. If a value already exists in the specified position, the new value overwrites the old value. If the given index is greater than the length of the <b>JSONArray</b>, then null elements will be added as necessary to pad it out.
2141
]]></description>
2242

2343
</root>

content/api_en/JSONArray_setString.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
JSONArray json;
16+
17+
void setup() {
18+
19+
json = new JSONArray();
20+
21+
json.setInt(0, 32);
22+
json.setFloat(1, 1.13);
23+
json.setString(2, "grape");
24+
json.setBoolean(3, true);
25+
26+
println(json);
27+
}
28+
29+
// Sketch prints:
30+
// [
31+
// 32,
32+
// 1.1299999952316284,
33+
// "grape",
34+
// true
35+
// ]
1636
]]></code>
1737
</example>
1838

1939
<description><![CDATA[
20-
To come...
40+
Inserts a new value into the <b>JSONArray</b> at the specified index position. If a value already exists in the specified position, the new value overwrites the old value. If the given index is greater than the length of the <b>JSONArray</b>, then null elements will be added as necessary to pad it out.
2141
]]></description>
2242

2343
</root>

0 commit comments

Comments
 (0)