JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

spork/json/decode

spork


    cfunction

    (json/decode json-source &opt keywords nils)

    Returns a janet object after parsing JSON. If keywords is truthy, 
    string keys will be converted to keywords. If nils is truthy, null 
    will become nil instead of the keyword :null.


1 exampleSign in to add an example
Loading...
(import spork/json)
(def input `` {"name": "person", "unknown": null, "happy": true, "sad": false} ``)

When calling, the json dictionary becomes a mutable table in janet.

(json/decode input)
@{"happy" true "name" "person" "sad" false "unknown" :null}

pass `true` as the first arg, and json keys become janet keywords.

(json/decode input true)
@{:happy true :name "person" :sad false :unknown :null}

pass `true` as the second arg, and json keys that map to `null` are not hydrated.

(json/decode input true true)
@{:happy true :name "person" :sad false}



nickfunPlayground