MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / asJson

Method asJson

java/src/org/openqa/selenium/remote/http/Contents.java:160–168  ·  view source on GitHub ↗

@return an Supplier containing the object converted to a UTF-8 JSON string.

(Object obj)

Source from the content-addressed store, hash-verified

158 * @return an {@link Supplier} containing the object converted to a UTF-8 JSON string.
159 */
160 public static Supplier asJson(Object obj) {
161 ByteArrayOutputStream output = new ByteArrayOutputStream();
162 try (JsonOutput out = JSON.newOutput(new OutputStreamWriter(output, UTF_8))) {
163 out.setPrettyPrint(false);
164 out.writeClassName(false);
165 out.write(obj);
166 }
167 return bytes(output.toByteArray());
168 }
169
170 public static <T> T fromJson(HttpMessage<?> message, Type typeOfT) {
171 try (Reader reader = reader(message);

Calls 6

bytesMethod · 0.95
newOutputMethod · 0.80
setPrettyPrintMethod · 0.80
writeClassNameMethod · 0.80
toByteArrayMethod · 0.80
writeMethod · 0.45