Skip to content

About

Easy-to-write JSON-like data structure for Julia

Resources

Stars

42 stars

Watchers

1 watching

Forks

Latest commit

 

History

87 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status deps version pkgeval

EasyConfig

  • EasyConfig provides a friendly-syntax, nested AbstractDict{Symbol, Any} data structure.
  • The advantages over other AbstractDict/NamedTuples are:

1) Intermediate levels are created on the fly:

  • This is quite convenient for working with JSON specs (e.g. PlotlyLight.jl).
c = Config()
c.one.two.three = 1

  • Compare this to OrderedDict and NamedTuple:
c = OrderedDict(:one => OrderedDict(:two => OrderedDict(:three => 1)))

c = (one = (two = (three = 1,),),)

c = (; one = (;two = (;three = 1)))



2) Easy to Use Both Interactively and Programmatically

  • You can use any combination of String/Symbol with getproperty/getindex.
  • For working interactively, getproperty is the most convenient to work with.
  • For working programmatically, getindex is the most convenient to work with.
# getproperty
c.one.two.three

# getindex
c[:one][:two][:three]

# mix and match
c["one"].two."three"



@config

Create a Config with a NamedTuple-like or block syntax. The following examples create equivalent Configs:

@config (x.one=1, x.two=2, z=3)

@config x.one=1 x.two=2 z=3

@config begin
    x.one = 1
    x.two = 2
    z = 3
end

let
    c = Config()
    c.x.one = 1
    c.x.two = 2
    c.z = 3
end

Note

  • Accessing a non-existent property creates an Undefined.
  • This is necessary for assigning deeply nested properties (an eventual setindex! after nested getindex-es).
    • config.a == Undefined(config, [:a]), config.a.b == Undefined(config, [:a, :b]), etc.
    • config.a.b.c = 1 == Undefined(config, [:a, :b])[:c] = 1

About

Easy-to-write JSON-like data structure for Julia

Resources

Stars

42 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages