JanetDocsPlaygroundI'm feeling luckyGitHub sign in

parse



    function
    boot.janet on line 2555, column 1

    (parse str)

    Parse a string and return the first value. For complex parsing, 
    such as for a repl with error handling, use the parser api.


3 examplesSign in to add an example
Loading...
# `parse` can decode arbitrary JDN (Janet Data Notation) encoded by `string/format`

(def encoded (string/format "%j" @{:a 123 :b "foo" :c @{1 [1.2 2.3 3.4]}}))
# => "@{:a 123 :b \"foo\" :c @{1 @[1.2 2.2999999999999998 3.3999999999999999]}}"

(parse encoded)
# => @{:a 123 :b "foo" :c @{1 @[1.2 2.3 3.4]}}
CFiggersPlayground
(parse "(+ 4 5)") # => (+ 4 5)
(type (parse "(+ 4 5)")) # => :tuple
skuzzymigletPlayground
(parse "[:a :b :c]") # => [:a :b :c]
sogaiuPlayground