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

Method toJson

gson/src/main/java/com/google/gson/Gson.java:542–547  ·  view source on GitHub ↗

This method serializes the specified object into its equivalent JSON representation. This method should be used when the specified object is not a generic type. This method uses {@link Class#getClass()} to get the type for the specified object, but the {@code getClass()} loses the generic type infor

(Object src)

Source from the content-addressed store, hash-verified

540 * @see #toJson(Object, Type)
541 */
542 public String toJson(Object src) {
543 if (src == null) {
544 return toJson(JsonNull.INSTANCE);
545 }
546 return toJson(src, src.getClass());
547 }
548
549 /**
550 * This method serializes the specified object, including those of generic types, into its

Callers 15

customStringAdapterMethod · 0.95
testMainPackageMethod · 0.95
testSerializationMethod · 0.95
testSerializationMethod · 0.95
testSerializedNameMethod · 0.95
testCustomAdapterMethod · 0.95
testSerializedNameMethod · 0.95
testCustomAccessorMethod · 0.95

Calls 13

newJsonWriterMethod · 0.95
writerForAppendableMethod · 0.95
getAdapterMethod · 0.95
getMethod · 0.95
writeMethod · 0.95
isHtmlSafeMethod · 0.80
getSerializeNullsMethod · 0.80
setHtmlSafeMethod · 0.80
setSerializeNullsMethod · 0.80
toStringMethod · 0.65
getStrictnessMethod · 0.45
setStrictnessMethod · 0.45

Tested by 15

customStringAdapterMethod · 0.76
testMainPackageMethod · 0.76
testSerializationMethod · 0.76
testSerializationMethod · 0.76
testSerializedNameMethod · 0.76
testCustomAdapterMethod · 0.76
testSerializedNameMethod · 0.76
testCustomAccessorMethod · 0.76