Skip to content

Commit 9f3432b

Browse files
author
Marius Posta
committed
java CDK: add static deserialize*(byte[]) methods to Jsons
1 parent ef473c5 commit 9f3432b

File tree

1 file changed

+16
-0
lines changed
  • airbyte-cdk/java/airbyte-cdk/dependencies/src/main/java/io/airbyte/commons/json

1 file changed

+16
-0
lines changed

airbyte-cdk/java/airbyte-cdk/dependencies/src/main/java/io/airbyte/commons/json/Jsons.java

+16
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,22 @@ public static JsonNode deserializeExact(final String jsonString) {
117117
}
118118
}
119119

120+
public static JsonNode deserialize(final byte[] jsonBytes) {
121+
try {
122+
return OBJECT_MAPPER.readTree(jsonBytes);
123+
} catch (final IOException e) {
124+
throw new RuntimeException(e);
125+
}
126+
}
127+
128+
public static JsonNode deserializeExact(final byte[] jsonBytes) {
129+
try {
130+
return OBJECT_MAPPER_EXACT.readTree(jsonBytes);
131+
} catch (final IOException e) {
132+
throw new RuntimeException(e);
133+
}
134+
}
135+
120136
public static <T> Optional<T> tryDeserialize(final String jsonString, final Class<T> klass) {
121137
try {
122138
return Optional.of(OBJECT_MAPPER.readValue(jsonString, klass));

0 commit comments

Comments
 (0)