allenap/elm-json-decode-broken/1.0.0

NOTE: the latest version is 3.0.2

Json.Decode.Broken

Decode broken JSON.

Parsing

parse : String -> Result (List DeadEnd) Value

Parse the given JSON string.

Errors come straight from elm/parser and may not be super useful. It may be worth changing this parser to use elm/parser's Parser.Advanced which allows more control over errors.

type Value
= Object (List ( String, Value ))
| Array (List Value)
| String String
| Number Int Frac Exp
| True
| False
| Null

Custom type for JSON values.

Mostly this is self-explanatory, but numbers might be interesting because no effort is made to convert them to Float values. This means you can deal with overflows or precision mismatches in broken JSON.

Numbers

type Frac
= Frac Int
| NoFrac

Does the number have a fractional component?

i.e. the optional part after the decimal point.

type Exp
= Exp Sign Int
| NoExp

Does the number have an exponent?

i.e. an optional suffix starting with e or E in the number.

type Sign
= Plus
| Minus
| NoSign

The sign of the exponent.