~pvigo/+junk/processing-3.1.2

« back to all changes in this revision

Viewing changes to debian/processing/usr/share/processing-3.1.2/modes/java/reference/JSONArray_getJSONObject_.html

  • Committer: Pablo Vigo
  • Date: 2016-08-16 10:54:55 UTC
  • Revision ID: pvigo@xtec.cat-20160816105455-4y3x00r4w5anrpr4
2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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">
 
3
        <head>
 
4
                <title>JSONArray::getJSONObject() \ Language (API) \ Processing 2+</title>
 
5
 
 
6
                <link rel="icon" href="/favicon.ico" type="image/x-icon" />
 
7
 
 
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" />
 
14
 
 
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" />
 
17
 
 
18
        </head>
 
19
        <body id="Langauge-en" onload="" >
 
20
 
 
21
                <!-- ==================================== PAGE ============================ -->
 
22
                <div id="container">
 
23
 
 
24
 
 
25
                        <!-- ==================================== HEADER ============================ -->
 
26
 
 
27
                        <div id="ribbon">
 
28
                                <ul class="left">
 
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>
 
33
                                </ul>
 
34
                                <ul class="right">
 
35
                                        <li><a href="https://processingfoundation.org/">Processing Foundation</a></li>
 
36
                                </ul>
 
37
                                <div class="clear"></div>
 
38
                        </div>
 
39
                        <div id="header">
 
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>
 
45
                                </form>
 
46
                        </div>
 
47
                        <a id="TOP" name="TOP"></a>
 
48
 
 
49
                        <div id="navigation">
 
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>
 
55
</div>
 
56
 
 
57
<script> document.querySelectorAll(".processing-logo")[0].className = "processing-logo"; </script>
 
58
                        </div>
 
59
 
 
60
                        <!-- ==================================== CONTENT - Headers ============================ -->
 
61
                        <div class="content">
 
62
 
 
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>
 
64
 
 
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>
 
67
 
 
68
        <tr class="name-row">
 
69
                <th scope="row">Name</th>
 
70
 
 
71
                <td><h3>getJSONObject()</h3></td>
 
72
        </tr>
 
73
 
 
74
        <tr class="">
 
75
 
 
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.
 
79
//
 
80
// [
 
81
//   {
 
82
//     "id": 0,
 
83
//     "species": "Capra hircus",
 
84
//     "name": "Goat"
 
85
//   },
 
86
//   {
 
87
//     "id": 1,
 
88
//     "species": "Panthera pardus",
 
89
//     "name": "Leopard"
 
90
//   },
 
91
//   {
 
92
//     "id": 2,
 
93
//     "species": "Equus zebra",
 
94
//     "name": "Zebra"
 
95
//   }
 
96
// ]
 
97
 
 
98
JSONArray values;
 
99
 
 
100
void setup() {
 
101
 
 
102
  values = loadJSONArray("data.json");
 
103
 
 
104
  for (int i = 0; i < values.size(); i++) {
 
105
    
 
106
    JSONObject animal = values.getJSONObject(i); 
 
107
 
 
108
    int id = animal.getInt("id");
 
109
    String species = animal.getString("species");
 
110
    String name = animal.getString("name");
 
111
 
 
112
    println(id + ", " + species + ", " + name);
 
113
  }
 
114
}
 
115
 
 
116
// Sketch prints:
 
117
// 0, Capra hircus, Goat
 
118
// 1, Panthera pardus, Leopard
 
119
// 2, Equus zebra, Zebra
 
120
</pre></div>
 
121
</td></tr>
 
122
 
 
123
                <tr class="">
 
124
                <th scope="row">Description</th>
 
125
                <td>
 
126
Retrieves the <b>JSONObject</b> with the associated index value.
 
127
</td>
 
128
        </tr>
 
129
 
 
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>
 
132
 
 
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>
 
141
</table>
 
142
 
 
143
Updated on June 24, 2016 00:34:49pm EDT<br /><br />
 
144
 
 
145
<!-- Creative Commons License -->
 
146
 
 
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>
 
149
</div>
 
150
<!--
 
151
 
 
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>
 
158
    </rdf:Description>
 
159
    <rdf:Description rdf:about=''
 
160
                     xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'
 
161
                     >
 
162
      <xapRights:UsageTerms>
 
163
        <rdf:Alt>
 
164
          <rdf:li xml:lang='x-default' >This work is licensed under a &lt;a rel=&#34;license&#34; href=&#34;http://creativecommons.org/licenses/by-nc-sa/4.0/&#34;&gt;Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License&lt;/a&gt;.</rdf:li>
 
165
          <rdf:li xml:lang='en' >This work is licensed under a &lt;a rel=&#34;license&#34; href=&#34;http://creativecommons.org/licenses/by-nc-sa/4.0/&#34;&gt;Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License&lt;/a&gt;.</rdf:li>
 
166
          </rdf:Alt>
 
167
      </xapRights:UsageTerms>
 
168
    </rdf:Description>
 
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/'/>
 
172
    </rdf:Description>
 
173
 
 
174
  </rdf:RDF>
 
175
</x:xmpmeta>
 
176
<?xpacket end='r'?>
 
177
 
 
178
-->
 
179
 
 
180
                        </div>
 
181
 
 
182
                        <!-- ==================================== FOOTER ============================ -->
 
183
                        <div id="footer">
 
184
 
 
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>
 
186
                        <div id="colophon">
 
187
 
 
188
                    <a href="copyright.html">&copy; Info</a>
 
189
 
 
190
                </div>
 
191
                        </div>
 
192
 
 
193
                </div>
 
194
                <script src="javascript/jquery-1.9.1.min.js"></script>
 
195
                <script src="javascript/site.js" type="text/javascript"></script>
 
196
        </body>
 
197
</html>