Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I am reading the below json content from a file and converting into a map but i am getting the below exception. Kindly let me know if anybody has come across such issue. I validated my json content and looks valid. Not sure why this error.
Json Content:
"Results":[{
"TotalPositiveFeedbackCount": 0
"TotalPositiveFeedbackCount": 1
} ]
Code:
Map<String, Object> domainMap = new HashMap<String, Object>();
try {
responseJson = getFile("reviewresponse.json");
//responseJson = new String(Files.readAllBytes(Paths.get("reviewresponse.json")), StandardCharsets.UTF_8);
ObjectMapper jsonObjectMapper = new ObjectMapper();
jsonObjectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
domainMap = jsonObjectMapper.readValue(responseJson,
new TypeReference<Map<String, Object>>() {});
Exception Details:
com.fasterxml.jackson.core.JsonParseException: Unexpected character (' ' (code 160)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name
at [Source: {
"Results":[{
"TotalPositiveFeedbackCount": 0
"TotalPositiveFeedbackCount": 1
} ]
; line: 2, column: 15]
–
–
–
–
Google for Json formatter then click on any one of the option ,
Paste your json code in that formatter , it will validate & highlight the unwanted characters just delete them or replace then with what you want.
e.g. goto https://jsonformatter.org/
& follow the above steps
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.