dummy-link

Unmarshal

Implements a Julia Unmarshal package, which will construct Julia objects from a marshalled string after having been parsed by another package (currently JSON.jl and LaxyJSON.jl has been tested).

Readme

Unmarshal

Unmarshalling parsed format dictionaries into Julia Objects

Build Status

Coverage Status

codecov.io

Installation: pkg> add Unmarshal

Basic Usage

This package has currently only been tested with unmarshalling of JSON objects, but the intention is to in future also test it for working on other data formats.

import Unmarshal

using JSON

input = "{ \"bar\": { \"baz\": 17 }, \"foo\": 3.14 }"

struct Bar
    baz::Int
end

struct Foo
    bar::Bar
end

Unmarshal.unmarshal(Foo, JSON.parse(input))
# Foo(Bar(17))
jstring = JSON.json(ones(Float64, 3))
#"[1.0,1.0,1.0]"

Unmarshal.unmarshal(Array{Float64}, JSON.parse(jstring))
#3-element Array{Float64,1}:
# [ 1.0 ; 1.0 ; 1.0 ]
using LazyJSON

#"[1.0,1.0,1.0]"

Unmarshal.unmarshal(Array{Float64}, JSON.parse(jstring))
#3-element Array{Float64,1}:
# [ 1.0 ; 1.0 ; 1.0 ]

Documentation

Unmarshal.unmarshal(MyType, parseOutput, verbose = false )

Builds on object of type :MyType from the dictionary produced by JSON.parse or now also LazyJSON.parse. Set verbose to true to get debug information about the type hierarchy beging unmarshalled. This might be useful in tracking down mismatches between the JSON object and the Julia type definition.

First Commit

02/02/2017

Last Touched

about 1 month ago

Commits

56 commits