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

trying out a toJSON() method · processing/processing@030ff8e · GitHub

Repository navigation

Commit 030ff8e

Browse files
committed
trying out a toJSON() method
1 parent 62f5089 commit 030ff8e

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎core/src/processing/data/IntDict.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,22 @@ public void write(PrintWriter writer) {
660660
}
661661

662662

663+
/**
664+
* Return this dictionary as a String in JSON format.
665+
*/
666+
public String toJSON() {
667+
StringList items = new StringList();
668+
for (int i = 0; i < size(); i++) {
669+
items.append("\"" + keys[i] + "\": " + values[i]);
670+
}
671+
return "{ " + items.join(", ") + " }";
672+
}
673+
674+
663675
@Override
664676
public String toString() {
677+
return getClass().getSimpleName() + " size=" + size() + " " + toJSON();
678+
/*
665679
StringBuilder sb = new StringBuilder();
666680
sb.append(getClass().getSimpleName() + " size=" + size() + " { ");
667681
for (int i = 0; i < size(); i++) {
@@ -672,5 +686,6 @@ public String toString() {
672686
}
673687
sb.append(" }");
674688
return sb.toString();
689+
*/
675690
}
676691
}

‎core/todo.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
X some Table cleanup based on other CSV parsing work
33
X use StandardCharsets.UTF_8 instead of getting encoding by name
44
X PApplet.main(Blah.class) now works
5+
X add toJSON() method to IntDict
6+
_ do the same for the other data classes
7+
_ note the difference between this and toJSONObject() or toJSONArray()
8+
_ or is that the better way to handle it? hm
59

610

711
_ Can't render PGraphics object using image() within a PDF

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL