'jackson objectMapper.readValue fails on empty values
I'm trying to read this json file into a Map { "1": 0, "2": 1, "3": , "4": 5 } my json is very simple but as you see in the example it can have a key with an empty value (null value) on "3". parsing it by:
Map<String, Object> testMap = objectMapper.readValue(file.getInputStream(), Map.class);
fails with "Unexpected character (',' (code 44)): expected a value"
is there any way to make this work?
Thanks
Solution 1:[1]
{ "1": 0, "2": 1, "3": , "4": 5 } is not a valid JSON, so any standard parser would fail. You can customize a parser or (better) use a regex to substitute the "key": , with "key": null,.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dcolazin |
