Parse/decode broken JSON.
When successful, parsing returns a Json.Encode.Value. Use with with
Json.Decode.decodeValue to extract the information you need into your
application's data structures.
A parser for a JSON value is:
Parser.oneOf [ object, array, string, number, true, false, null ]According to the specification, a JSON document is optional
whitespace, a JSON value (that oneOf … expression above), then more optional
whitespace – and that's what the json parser does. Hence parsing a compliant
JSON document is nothing more than:
Parser.run json "…"Use these building blocks to compose a parser for broken JSON as you need. If
you need to parse non-compliant quoted strings, for example, it might be best to
copy just the string code from this module into your project, and use the
other parsers in this module – object, array, and so on – to compose a new
parser.
Parser for JSON.
This is a JSON value surrounded by optional whitespace.
Parser for a JSON object.
Parser for a JSON array.
Parser for a quoted JSON string.
string and some of its helpers have been adapted from elm/parser's
DoubleQuoteString example.
Parser for a JSON number.
Parser for a JSON 'true' literal.
Parser for a JSON 'false' literal.
Parser for a JSON 'null' literal.
Parser for JSON whitespace.
This is the whitespace that appears between significant elements of JSON, and before and after JSON documents, not whitespace within quoted strings.
Parse the given JSON string.
This assumes a spec-compliant JSON string; it will choke on "broken" JSON. This seems kind of weird for a package that's all about parsing broken JSON. However, we all have to start somewhere. Read the code, copy it, modify it, make it work for your use case.
Errors come straight from elm/parser and may not be super useful. Sorry.