4{-| Library for working with [JSON](https://en.wikipedia.org/wiki/JSON) values.
6@docs Value, fromString, toString
14{-| This datatype can represent all valid JSON values. A `Value` can be sent
15through ports, and the runtime will do a conversion like this:
17 [2,'abc',null] == Array [Number 2, String "abc", Null]
19JSON is an intentional subset of JavaScript values which excludes functions.
20This ensures that impure functions cannot sneak into Elm through ports.
28 | Object (Dict.Dict String Value)
31{-| Convert a `Value` into a prettified string.
32The first argument is a separator token (e.g. \" \", \"\\n\", etc.) that will
33be used for indentation in the prettified string version of the JSON.
35 toString "" Null == "null"
36 toString "" (Number 4.0) == "4.0"
38toString : String -> Value -> String
39toString sep value = Native.Json.toString sep value
41{-| Parse a string representation of a proper JSON object into
42its Elm representation.
44 fromString "null" == Just Null
45 fromString "[true,3]" == Just (Array [Boolean True, Number 3])
46 fromString "{'abc':4}" == Just (Object (Dict.fromList [("abc", Number 4)]))
48fromString : String -> Maybe Value
49fromString str = Native.Json.fromString str
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list