We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonHelper is a tool to help unit test of json serialization / deserialization
JsonHelper
public final class JsonHelper { private static final ObjectMapper jsonMapper = jsonMapper(); private JsonHelper() {} public static ObjectMapper jsonMapper() { return JsonMapper .builder() .serializationInclusion(JsonInclude.Include.NON_EMPTY) .addModule(new JavaTimeModule()) .addModules(new Jdk8Module()) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY) .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .build(); } public static <T> String writeAsString(T object) { try { return jsonMapper.writeValueAsString(object); } catch (JsonProcessingException e) { throw new AssertionError("Error serializing object: " + e.getMessage(), e); } } public static <T> T readFromJson(String json, Class<T> clazz) { try { return jsonMapper.readValue(json, clazz); } catch (IOException e) { throw new AssertionError("Error reading value from json: " + e.getMessage(), e); } } }
The text was updated successfully, but these errors were encountered:
When do you think we should generate this? Java base or something related to Spring Boot? I'd say the 2nd option.
Sorry, something went wrong.
I think we should add it it spring MVC.
When done we'll need to use that in code for dummy feature (#2444)
Successfully merging a pull request may close this issue.
JsonHelper
is a tool to help unit test of json serialization / deserializationThe text was updated successfully, but these errors were encountered: