| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -660,8 +660,22 @@ public void write(PrintWriter writer) { | |||
| 660 | 660 | } | |
| 661 | 661 | ||
| 662 | 662 | ||
| 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 | + | ||
| 663 | 675 | @Override | |
| 664 | 676 | public String toString() { | |
| 677 | + return getClass().getSimpleName() + " size=" + size() + " " + toJSON(); | ||
| 678 | + /* | ||
| 665 | 679 | StringBuilder sb = new StringBuilder(); | |
| 666 | 680 | sb.append(getClass().getSimpleName() + " size=" + size() + " { "); | |
| 667 | 681 | for (int i = 0; i < size(); i++) { | |
@@ -672,5 +686,6 @@ public String toString() { | |||
| 672 | 686 | } | |
| 673 | 687 | sb.append(" }"); | |
| 674 | 688 | return sb.toString(); | |
| 689 | + */ | ||
| 675 | 690 | } | |
| 676 | 691 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,10 @@ | |||
| 2 | 2 | X some Table cleanup based on other CSV parsing work | |
| 3 | 3 | X use StandardCharsets.UTF_8 instead of getting encoding by name | |
| 4 | 4 | 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 | ||
| 5 | 9 | ||
| 6 | 10 | ||
| 7 | 11 | _ Can't render PGraphics object using image() within a PDF | |
| Back | FazBrowse Home | New Git URL |
0 commit comments