Search code examples
jsonvalidationrfc4627

JSON validation fails (RFC 4627)


I have an Api method which returns json data. When I try to validate the json data using the online json validator: http://pro.jsonlint.com/, with the compare option, giving url in one section and the output of the url in another section, the url section shows an error and the section with data copied and pasted is validated.

What could be the issue here?

json_validation

UPDATE: I copied the 2 outputs into notepad and did a file compare, there is a non-printable character at the begining of the output from url.

D:\>fc j1.js j2.js

Comparing files j1.js and J2.JS

***** j1.js

{

    "responseStatus": null,

***** J2.JS

{

    "responseStatus": null,

*****

The content-type of the api response is "application/json; charset=utf-8".


Solution

  • Without knowledge of your locale and character set, this is speculation; but the placement of the spurious text suggests that it may be a Unicode BOM. (Hmmm, six bytes? Two UTF-8 BOMs?)