MCPcopy Index your code
hub / github.com/benfry/processing4 / writeInternal

Method writeInternal

core/src/processing/data/JSONObject.java:1872–1920  ·  view source on GitHub ↗

Write the contents of the JSONObject as JSON text to a writer. Warning: This method assumes that the data structure is acyclical. @return The writer. @throws RuntimeException

(Writer writer, int indentFactor, int indent)

Source from the content-addressed store, hash-verified

1870 * @throws RuntimeException
1871 */
1872 protected Writer writeInternal(Writer writer, int indentFactor, int indent) {
1873 try {
1874 boolean commanate = false;
1875 final int length = this.size();
1876 Iterator keys = this.keyIterator();
1877 writer.write('{');
1878
1879 int actualFactor = (indentFactor == -1) ? 0 : indentFactor;
1880
1881 if (length == 1) {
1882 Object key = keys.next();
1883 writer.write(quote(key.toString()));
1884 writer.write(':');
1885 if (actualFactor > 0) {
1886 writer.write(' ');
1887 }
1888 //writeValue(writer, this.map.get(key), actualFactor, indent);
1889 writeValue(writer, this.map.get(key), indentFactor, indent);
1890 } else if (length != 0) {
1891 final int newIndent = indent + actualFactor;
1892 while (keys.hasNext()) {
1893 Object key = keys.next();
1894 if (commanate) {
1895 writer.write(',');
1896 }
1897 if (indentFactor != -1) {
1898 writer.write('\n');
1899 }
1900 indent(writer, newIndent);
1901 writer.write(quote(key.toString()));
1902 writer.write(':');
1903 if (actualFactor > 0) {
1904 writer.write(' ');
1905 }
1906 //writeValue(writer, this.map.get(key), actualFactor, newIndent);
1907 writeValue(writer, this.map.get(key), indentFactor, newIndent);
1908 commanate = true;
1909 }
1910 if (indentFactor != -1) {
1911 writer.write('\n');
1912 }
1913 indent(writer, indent);
1914 }
1915 writer.write('}');
1916 return writer;
1917 } catch (IOException exception) {
1918 throw new RuntimeException(exception);
1919 }
1920 }
1921
1922
1923// // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 2

formatMethod · 0.95
writeValueMethod · 0.45

Calls 10

sizeMethod · 0.95
keyIteratorMethod · 0.95
quoteMethod · 0.95
writeValueMethod · 0.95
indentMethod · 0.95
writeMethod · 0.65
nextMethod · 0.65
getMethod · 0.65
toStringMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected