### Question:
SphereJsonUtils { public static <T> T readObject(final String jsonAsString, final TypeReference<T> typeReference) { return executing(() -> objectMapper.readValue(jsonAsString, typeReference)); } private  SphereJsonUtils(); static ObjectMapper newObjectMapper(); static ObjectMapper configureObjectMapper(final ObjectMapper objectMapper); static String toJsonString(final Object value); static String toPrettyJsonString(final Object value); static JsonNode toJsonNode(final Object value); static JsonNode parse(final String jsonAsString); static JsonNode parse(final byte[] jsonAsBytes); static String prettyPrint(final String json); static String prettyPrint(final JsonNode jsonNode); static T readObjectFromResource(final String resourcePath, final TypeReference<T> typeReference); static T readObjectFromResource(final String resourcePath, final JavaType javaType); static T readObjectFromResource(final String resourcePath, final Class<T> clazz); static T readObject(final String jsonAsString, final TypeReference<T> typeReference); static T readObject(final String jsonAsString, final Class<T> clazz); static T readObject(final JsonNode jsonNode, final TypeReference<T> typeReference); static T readObject(final JsonNode jsonNode, final Class<T> clazz); static T readObject(final JsonNode jsonNode, final JavaType javaType); static T readObject(final byte[] jsonAsBytes, final TypeReference<T> typeReference); static T readObject(final byte[] jsonAsBytes, final JavaType javaType); static ObjectNode newObjectNode(); static JavaType convertToJavaType(final TypeReference<T> typeReference); static JavaType createCustomObjectJavaType(Class<?> customObject, Class<?> param); static JavaType convertToJavaType(final Class<?> clazz);  }### Answer:
@Test public void deserializelLocale() { final String jsonString = "\"en\""; final Locale locale = SphereJsonUtils.readObject(jsonString, TypeReferences.localeTypeReference()); assertThat(locale).isEqualTo(Locale.ENGLISH); }
@Test public void deserializeFullLocale() { final String jsonString = "\"en-US\""; final Locale locale = SphereJsonUtils.readObject(jsonString, TypeReferences.localeTypeReference()); assertThat(locale).isEqualTo(Locale.US); }
@Test public void deserializeZonedDateTime() throws Exception { final String timeAsString = "2001-09-11T14:00:00.000Z"; final ZonedDateTime actual = SphereJsonUtils.readObject(("\"" + timeAsString + "\"").getBytes(), TypeReferences.zonedDateTimeTypeReference()); assertThat(DateTimeFormatter.ISO_INSTANT.format(actual)).isEqualTo("2001-09-11T14:00:00Z"); }
@Test public void readObjectFromJsonString() throws Exception { final String jsonString = "{\"de\":\"Hundefutter\",\"en\":\"dog food\"}"; final LocalizedString actual = SphereJsonUtils.readObject(jsonString, LocalizedString.typeReference()); assertThat(actual).isEqualTo(LocalizedString.of(ENGLISH, "dog food", GERMAN, "Hundefutter")); }
@Test public void exceptionHandling() throws Exception { final String brokenJsonString = "{\"de\":\",]]]]"; assertThatThrownBy(() -> SphereJsonUtils.readObject(brokenJsonString, LocalizedString.typeReference())) .isInstanceOf(JsonException.class); }