json-schema-ref-parser icon indicating copy to clipboard operation
json-schema-ref-parser copied to clipboard

Feature Request: Handle presence of byte order marking

Open dowlingw opened this issue 7 years ago • 2 comments

According to RFC 7159, documents with a byte order mark are not valid JSON: https://tools.ietf.org/html/rfc7159#section-8.1

Implementations MUST NOT add a byte order mark to the beginning of a JSON text. In the interests of interoperability, implementations that parse JSON texts MAY ignore the presence of a byte order mark rather than treating it as an error.

However, there are a number of notable specifications published that violate the standard. Example: https://github.com/Azure/azure-resource-manager-schemas

It is currently possible to work around this by wrapping the inbuilt JSON parser with a custom parser that strips the offending characters.

Suggesting that this might be common enough that it's worth adding a flag to the JSON parser to handle this until the upstream sources are able to revise their specifications.

dowlingw avatar Nov 26 '18 01:11 dowlingw

Great point! I definitely think this should be built-in functionality. I'd gladly accept a PR to add this.

JamesMessinger avatar Nov 28 '18 11:11 JamesMessinger

Thanks, I've got the code to do this ready to go - will throw some tests around it and put together a PR as soon as possible, thanks!

dowlingw avatar Nov 28 '18 13:11 dowlingw

Added this feature to v11

jonluca avatar Mar 06 '24 04:03 jonluca