JSON was converted into an object using Jackson 2.7.3 version.
Question 1. I want to check the JSON value before converting JSON into an object, how do I do it?
Question 2. If number 1 is possible, NULL processing is possible. If it's impossible, there's an error when there's no data when converting to an object, how should I handle it?
json java spring
Q1.
You can catch it with Json Processing Exception
ObjectMapper objectMapper = new ObjectMapper();
try {
JsonNode jsonNode = objectMapper.readTree(json);
///...
} } catch (JsonProcessingException e) {
e.printStackTrace();
///...
} } catch (IOException e) {
e.printStackTrace();
///...
}
© 2024 OneMinuteCode. All rights reserved.