1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
<title>JSONArray::getJSONObject() \ Language (API) \ Processing 2+</title>
6
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<meta name="Author" content="Processing Foundation" />
10
<meta name="Publisher" content="Processing Foundation" />
11
<meta name="Keywords" content="Processing, Sketchbook, Programming, Coding, Code, Art, Design" />
12
<meta name="Description" content="Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology." />
13
<meta name="Copyright" content="All contents copyright the Processing Foundation, Ben Fry, Casey Reas, and the MIT Media Laboratory" />
15
<script src="javascript/modernizr-2.6.2.touch.js" type="text/javascript"></script>
16
<link href="css/style.css" rel="stylesheet" type="text/css" />
19
<body id="Langauge-en" onload="" >
21
<!-- ==================================== PAGE ============================ -->
25
<!-- ==================================== HEADER ============================ -->
29
<li class="highlight"><a href="http://processing.org/">Processing</a></li>
30
<li><a href="http://p5js.org/">p5.js</a></li>
31
<li><a href="http://py.processing.org/">Processing.py</a></li>
32
<li><a href="http://android.processing.org/">Processing for Android</a></li>
35
<li><a href="https://processingfoundation.org/">Processing Foundation</a></li>
37
<div class="clear"></div>
40
<a href="/" title="Back to the Processing cover."><div class="processing-logo no-cover" alt="Processing cover"></div></a>
41
<form name="search" method="get" action="//www.google.com/search">
42
<p><input type="hidden" name="as_sitesearch" value="processing.org" />
43
<input type="text" name="as_q" value="" size="20" class="text" />
44
<input type="submit" value=" " /></p>
47
<a id="TOP" name="TOP"></a>
50
<div class="navBar" id="mainnav">
51
<a href="index.html" class='active'>Language</a><br>
52
<a href="libraries/index.html" >Libraries</a><br>
53
<a href="tools/index.html">Tools</a><br>
54
<a href="environment/index.html">Environment</a><br>
57
<script> document.querySelectorAll(".processing-logo")[0].className = "processing-logo"; </script>
60
<!-- ==================================== CONTENT - Headers ============================ -->
63
<p class="ref-notice">This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, <a href="https://github.com/processing/processing-docs/issues?state=open">please let us know</a>. If you prefer a more technical reference, visit the <a href="http://processing.github.io/processing-javadocs/core/">Processing Core Javadoc</a> and <a href="http://processing.github.io/processing-javadocs/libraries/">Libraries Javadoc</a>.</p>
65
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
66
<tr class=""><th scope="row">Class</th><td><p><a href="JSONArray.html">JSONArray</a></p></td></tr>
69
<th scope="row">Name</th>
71
<td><h3>getJSONObject()</h3></td>
76
<tr class=""><th scope="row">Examples</th><td><div class="example"><pre >
77
// The following short JSON file called "data.json" is parsed
78
// in the code below. It must be in the project's "data" folder.
83
// "species": "Capra hircus",
88
// "species": "Panthera pardus",
93
// "species": "Equus zebra",
102
values = loadJSONArray("data.json");
104
for (int i = 0; i < values.size(); i++) {
106
JSONObject animal = values.getJSONObject(i);
108
int id = animal.getInt("id");
109
String species = animal.getString("species");
110
String name = animal.getString("name");
112
println(id + ", " + species + ", " + name);
117
// 0, Capra hircus, Goat
118
// 1, Panthera pardus, Leopard
119
// 2, Equus zebra, Zebra
124
<th scope="row">Description</th>
126
Retrieves the <b>JSONObject</b> with the associated index value.
130
<tr class=""><th scope="row">Syntax</th><td><pre><kbd></kbd>.getJSONObject(<kbd>index</kbd>)
131
<kbd></kbd>.getJSONObject(<kbd>index</kbd>, <kbd>defaultValue</kbd>)</pre></td></tr>
133
<tr class=""> <th scope="row">Parameters</th><td><table cellpadding="0" cellspacing="0" border="0"><tr class="">
134
<th scope="row" class="code">index</th>
135
<td>int: the index value of the object to get</td>
136
</tr></table></td> </tr>
137
<tr class=""><th scope="row">Returns</th><td class="code">JSONObject</td></tr>
138
<tr class=""><th scope="row">Related</th><td><a class="code" href="JSONArray_getJSONArray_.html">getJSONArray()</a><br />
139
<a class="code" href="JSONArray_setJSONObject_.html">setJSONObject()</a><br />
140
<a class="code" href="JSONArray_setJSONArray_.html">setJSONArray()</a><br /></td></tr>
143
Updated on June 24, 2016 00:34:49pm EDT<br /><br />
145
<!-- Creative Commons License -->
147
<div class="license">
148
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border: none" src="http://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>
152
<?xpacket begin='' id=''?>
153
<x:xmpmeta xmlns:x='adobe:ns:meta/'>
154
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
155
<rdf:Description rdf:about=''
156
xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>
157
<xapRights:Marked>True</xapRights:Marked>
159
<rdf:Description rdf:about=''
160
xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'
162
<xapRights:UsageTerms>
164
<rdf:li xml:lang='x-default' >This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.</rdf:li>
165
<rdf:li xml:lang='en' >This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.</rdf:li>
167
</xapRights:UsageTerms>
169
<rdf:Description rdf:about=''
170
xmlns:cc='http://creativecommons.org/ns#'>
171
<cc:license rdf:resource='http://creativecommons.org/licenses/by-nc-sa/4.0/'/>
182
<!-- ==================================== FOOTER ============================ -->
185
<div id="copyright">Processing is an open project intiated by <a href="http://benfry.com/">Ben Fry</a> and <a href="http://reas.com">Casey Reas</a>. It is developed by a <a href="http://processing.org/about/people/">team of volunteers</a>.</div>
188
<a href="copyright.html">© Info</a>
194
<script src="javascript/jquery-1.9.1.min.js"></script>
195
<script src="javascript/site.js" type="text/javascript"></script>