Merge pull request #13189 from pjfanning/patch-1
need to handle trailing tokens
This commit is contained in:
commit
41d7305012
@ -1,11 +1,15 @@
|
|||||||
package com.baeldung.jsonvalidation;
|
package com.baeldung.jsonvalidation;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JacksonException;
|
import com.fasterxml.jackson.core.JacksonException;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||||
|
|
||||||
public class JacksonValidator {
|
public class JacksonValidator {
|
||||||
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = JsonMapper.builder()
|
||||||
|
.enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
|
||||||
|
.build();
|
||||||
|
|
||||||
public boolean isValid(String json) {
|
public boolean isValid(String json) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user