JSONParser returns Unexpected character () at position 0 JSONParser returns Unexpected character () at position 0 json json

JSONParser returns Unexpected character () at position 0


Most probably your content has some unprinted special character at beginning. For UTF-8 encoded data this may be a BOM.

Please post start of you content as byte[].


It is happening because of UTF-8 BOM.What is UTF-8 BOM ?The UTF-8 BOM is a sequence of bytes (EF BB BF) that allows the reader to identify a file as being encoded in UTF-8.

Normally, the BOM is used to signal the endianness of an encoding, but since endianness is irrelevant to UTF-8, the BOM is unnecessary.

How to solve the issue ?Convert encoding of your .json or any file to UTF-8 instead of UTF-8 BOM.Like this.

enter image description here


Use this instead of BufferReader

Map<String,Object> result             = (Map<String,Object>)JSONValue.parse(IOUtils.toString(response.getEntity().getContent(), "utf-8"));

You will get your JsonData into Map and simply you can iterate over map.