FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

cleanup JSON example more · wsedig/processing@7253d23 · GitHub

Repository navigation

Commit 7253d23

Browse files
committed
cleanup JSON example more
1 parent c6c8985 commit 7253d23

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎java/examples/Topics/Advanced Data/LoadSaveJSON/LoadSaveJSON.pde‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,19 @@ void draw() {
6363
bubbles = new Bubble[bubbleData.size()];
6464

6565
for (int i = 0; i < bubbleData.size(); i++) {
66+
// Get each object in the array
6667
JSONObject bubble = bubbleData.getObject(i);
68+
// Get a position object
6769
JSONObject position = bubble.getJSONObject("position");
70+
// Get x,y from position
6871
int x = position.getInt("x");
6972
int y = position.getInt("y");
70-
71-
float diameter = (float)bubble.getDouble("diameter");
73+
74+
// Get diamter and label
75+
float diameter = bubble.getFloat("diameter");
7276
String label = bubble.getString("label");
7377

78+
// Put object in array
7479
bubbles[i] = new Bubble(x, y, diameter, label);
7580
}
7681
}
@@ -85,7 +90,7 @@ void draw() {
8590
position.setInt("y", mouseY);
8691

8792
// Add position to bubble
88-
//newBubble.setJSONObject("position", position);
93+
newBubble.setJSONObject("position", position);
8994

9095
// Add diamater and label to bubble
9196
newBubble.setFloat("diameter", random(40, 80));

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL