MCPcopy Create free account
hub / github.com/MCBans/MCBans / write

Method write

src/main/java/com/mcbans/plugin/org/json/JSONObject.java:1602–1630  ·  view source on GitHub ↗

Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. Warning: This method assumes that the data structure is acyclical. @return The writer. @throws JSONException

(Writer writer)

Source from the content-addressed store, hash-verified

1600 * @throws JSONException
1601 */
1602 public Writer write(Writer writer) throws JSONException {
1603 try {
1604 boolean commanate = false;
1605 Iterator keys = keys();
1606 writer.write('{');
1607
1608 while (keys.hasNext()) {
1609 if (commanate) {
1610 writer.write(',');
1611 }
1612 Object key = keys.next();
1613 writer.write(quote(key.toString()));
1614 writer.write(':');
1615 Object value = this.map.get(key);
1616 if (value instanceof JSONObject) {
1617 ((JSONObject)value).write(writer);
1618 } else if (value instanceof JSONArray) {
1619 ((JSONArray)value).write(writer);
1620 } else {
1621 writer.write(valueToString(value));
1622 }
1623 commanate = true;
1624 }
1625 writer.write('}');
1626 return writer;
1627 } catch (IOException exception) {
1628 throw new JSONException(exception);
1629 }
1630 }
1631}

Callers

nothing calls this directly

Calls 6

keysMethod · 0.95
quoteMethod · 0.95
valueToStringMethod · 0.95
nextMethod · 0.80
toStringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected