algodynamics-iiith / core / Core.Analytics.Parser

This library is inspired from f0i/DebugToJson Convert Debug.toString output to JSON

Definition


type Thing
    = Obj (List ( String, Thing ))
    | Dct (List ( Thing, Thing ))
    | Arr (List Thing)
    | Set (List Thing)
    | Str String
    | MayBe (Maybe Thing)
    | Reslt (Result Thing Thing)
    | Custom String (List Thing)
    | Lst (List Thing)
    | Tpl (List Thing)
    | NumInt Basics.Int
    | NumFloat Basics.Float
    | Boolean Basics.Bool
    | Chr String
    | Fun
    | Intern
    | UnitType

The thing is an internal data structure to which the elm data types are parsed from the string This is exposed so that user can write custom JSON encoder specific to his usecase

Parser

parse : Parser Thing

this parser only parses core data types, Package specific data types built using Custom types (like IntDict) may not be easily human readable

Convert to JSON

toJson : String -> Result (List Parser.DeadEnd) Json.Encode.Value

Convert output from Debug.toString to JSON

Ecoders

encode : Thing -> Json.Encode.Value

Typed JSON encoder for Thing (parsed Debug.toString) output

encodeFlat : Thing -> Json.Encode.Value

Converts Elm Debug string to Flat JSON (does not include type information in the encoded data)