Hey i got an issue based on deserialization with jackson, here what i've tried and the error i got.
ERROR : com.fasterxml.jackson.core.JsonParseException: Unexpected character ('}' (code 125)): was expecting double-quote to start field name
Java Code
List<Contact> ds = mapper.readValue(data, mapper.getTypeFactory().constructCollectionType(List.class, Contact.class));
//OR this one
List<Contact> ds = mapper.readValue(data, new TypeReference<List<Contact>>() {});
My JSON
[
{
"id": "200",
"name": "Alexia Milano",
"email": "[email protected]",
"prenom": "xx-xx-xxxx,x - street, x - country",
}, {
"id": "201",
"name": "Johnny Depp",
"email": "[email protected]",
"prenom": "xx-xx-xxxx,x - street, x - country",
}
]
If you use json validator, you can see more detailed error message:
Parse error on line 6:
...ntry", }, { "id
---------------------^
Expecting 'STRING'
you have extra comma there after "xx-xx-xxxx,x - street, x - country"
. If you remove it from both two places, you have valid JSON and Jackson parsing works.
It's because your last entries, there is an ,
after your last value. Thats why jackson expects another field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With