@return an Supplier containing the object converted to a UTF-8 JSON string.
(Object obj)
| 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); |