hayd / JSON.jl

JSON parsing and printing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON.jl

Parsing and printing JSON in pure Julia.

Build Status Build status Coverage Status JSON

Installation: julia> Pkg.add("JSON")

Basic Usage

import JSON

# JSON.parse - string or stream to Julia data structures
s = "{\"a_number\" : 5.0, \"an_array\" : [\"string\", 9]}"
j = JSON.parse(s)
#  Dict{String,Any} with 2 entries:
#    "an_array" => {"string",9}
#    "a_number" => 5.0

# JSON.json - Julia data structures to a string
JSON.json([2,3])
#  "[2,3]"
JSON.json(j)
#  "{\"an_array\":[\"string\",9],\"a_number\":5.0}"

Documentation

JSON.print(io::IO, s::String)
JSON.print(io::IO, s::Union(Integer, FloatingPoint))
JSON.print(io::IO, n::Nothing)
JSON.print(io::IO, b::Bool)
JSON.print(io::IO, a::Associative)
JSON.print(io::IO, v::AbstractVector)
JSON.print{T, N}(io::IO, v::Array{T, N})

Writes a compact (no extra whitespace or identation) JSON representation to the supplied IO.

json(a::Any)

Returns a compact JSON representation as a String.

JSON.parse(s::String; ordered=false)
JSON.parse(io::IO; ordered=false)
JSON.parsefile(filename::String; ordered=false, use_mmap=true)

Parses a JSON String or IO stream into a nested Array or Dict.

If ordered=true is specified, JSON objects are parsed into OrderedDicts, which maintains the insertion order of the items in the object. (*)

(*) Requires the DataStructures.jl package to be installed.

About

JSON parsing and printing

License:Other


Languages

Language:Julia 100.0%