MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / toJson

Method toJson

CodenameOne/src/com/codename1/mapping/Mappers.java:103–116  ·  view source on GitHub ↗
(Object instance)

Source from the content-addressed store, hash-verified

101 /// at a missing `@Mapped` annotation or a build that ran without the
102 /// process-annotations Mojo.
103 public static String toJson(Object instance) {
104 if (instance == null) {
105 return "null";
106 }
107 @SuppressWarnings("unchecked")
108 Mapper<Object> m = (Mapper<Object>) BY_NAME.get(instance.getClass().getName());
109 if (m == null) {
110 throw missing(instance.getClass());
111 }
112 Map<String, Object> root = m.toMap(instance);
113 StringBuilder sb = new StringBuilder();
114 writeJson(sb, root);
115 return sb.toString();
116 }
117
118 /// Inverse of `#toJson`. Parses the JSON text and hands the resulting
119 /// Map to the registered mapper.

Callers 15

toJsonTreeMethod · 0.95
invoke0Method · 0.45
invoke1Method · 0.45
invoke3Method · 0.45
invokeStatic0Method · 0.45
invokeStatic7Method · 0.45
invokeStatic8Method · 0.45
invoke13Method · 0.45
invoke14Method · 0.45
runMethod · 0.45
mainMethod · 0.45
undoMethod · 0.45

Calls 7

missingMethod · 0.95
writeJsonMethod · 0.95
toStringMethod · 0.95
getMethod · 0.65
getNameMethod · 0.65
toMapMethod · 0.65
getClassMethod · 0.45

Tested by 5

runMethod · 0.36
mainMethod · 0.36