MCPcopy
hub / github.com/google/gson / toString

Method toString

gson/src/main/java/com/google/gson/JsonElement.java:420–433  ·  view source on GitHub ↗

Converts this element to a JSON string. <p>For example: <pre> JsonObject object = new JsonObject(); object.add("a", JsonNull.INSTANCE); JsonArray array = new JsonArray(); array.add(1); object.add("b", array); String json = object.toString(); // json: {"a":null,"b":[1]} </pre> If this element or

()

Source from the content-addressed store, hash-verified

418 * </pre>
419 */
420 @Override
421 public String toString() {
422 try {
423 StringBuilder stringBuilder = new StringBuilder();
424 JsonWriter jsonWriter = new JsonWriter(Streams.writerForAppendable(stringBuilder));
425 // Make writer lenient because toString() must not fail, even if for example JsonPrimitive
426 // contains NaN
427 jsonWriter.setStrictness(Strictness.LENIENT);
428 Streams.write(this, jsonWriter);
429 return stringBuilder.toString();
430 } catch (IOException e) {
431 throw new AssertionError(e);
432 }
433 }
434}

Callers

nothing calls this directly

Calls 4

writerForAppendableMethod · 0.95
setStrictnessMethod · 0.95
writeMethod · 0.95
toStringMethod · 0.65

Tested by

no test coverage detected