MCPcopy Create free account
hub / github.com/cmu-db/benchbase / toJSONString

Method toJSONString

src/main/java/com/oltpbenchmark/util/JSONUtil.java:123–139  ·  view source on GitHub ↗

@param object @return

(Object object)

Source from the content-addressed store, hash-verified

121 * @return
122 */
123 public static String toJSONString(Object object) {
124 JSONStringer stringer = new JSONStringer();
125 try {
126 if (object instanceof JSONSerializable) {
127 stringer.object();
128 ((JSONSerializable) object).toJSON(stringer);
129 stringer.endObject();
130 } else if (object != null) {
131 Class<?> clazz = object.getClass();
132 // stringer.key(clazz.getSimpleName());
133 JSONUtil.writeFieldValue(stringer, clazz, object);
134 }
135 } catch (JSONException e) {
136 throw new RuntimeException(e);
137 }
138 return (stringer.toString());
139 }
140
141 public static <T extends JSONSerializable> T fromJSONString(T t, String json) {
142 try {

Callers 11

writeJSONHistogramsMethod · 0.95
collectParametersMethod · 0.95
collectMetricsMethod · 0.95
collectMetricsMethod · 0.95
saveProfileMethod · 0.95
writeSummaryMethod · 0.95
toJSONStringMethod · 0.95
testToJSONStringMethod · 0.45
testFromJSONMethod · 0.45
saveProfileMethod · 0.45
saveMethod · 0.45

Calls 4

writeFieldValueMethod · 0.95
getClassMethod · 0.80
toJSONMethod · 0.65
toStringMethod · 0.45

Tested by 2

testToJSONStringMethod · 0.36
testFromJSONMethod · 0.36