MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / asJson

Method asJson

java/src/org/openqa/selenium/remote/http/Contents.java:160–167  ·  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.writeClassName(false);
164 out.write(obj);
165 }
166 return bytes(output.toByteArray());
167 }
168
169 public static <T> T fromJson(HttpMessage<?> message, Type typeOfT) {
170 try (Reader reader = reader(message);

Calls 5

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