properly put escapes on strings

This commit is contained in:
Ben Fry
2016-08-09 18:35:21 -04:00
parent c3bd8506b7
commit 6cf8e399fe
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -666,7 +666,7 @@ public class IntDict {
public String toJSON() {
StringList items = new StringList();
for (int i = 0; i < size(); i++) {
items.append("\"" + keys[i] + "\": " + values[i]);
items.append("\"" + JSONObject.quote(keys[i]) + "\": " + values[i]);
}
return "{ " + items.join(", ") + " }";
}
+1
View File
@@ -3,6 +3,7 @@ X some Table cleanup based on other CSV parsing work
X use StandardCharsets.UTF_8 instead of getting encoding by name
X PApplet.main(Blah.class) now works
X add toJSON() method to IntDict
X had to use JSONObject.quote() to wrap the text
_ do the same for the other data classes
_ note the difference between this and toJSONObject() or toJSONArray()
_ or is that the better way to handle it? hm