Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: parser can't handle Byte Order Mark #12254
Trying to parse a json file that contains a byte order mark results in an error
// LocaleMessage represents a single translation for an entry in the localization map.
lj := make(map[string]LocaleMessage)
The error message returned while trying to unmarshal:
The json file in question is from a chrome extension that ships with ChromeOS (I seem not to be able to attach the json file -> unsupported file type).
When I trim the first 3 bytes, it parses just fine.
This has come up before. We don't like BOMs. And JSON shouldn't have them anyway. (XML might have a slightly better excuse)
You should just strip them yourself. You can write a function or new io.Reader wrapper to do it. They probably already exist on godoc.org.