Cson is a project mainly written in C++ and C, based on the View license.
A Json-like data format: C++ and Haskell libraries
One can define values for structures with named fields,
lists, and simple literals - numbers, strings, booleans and null
. The syntax is
specified in bnfc/Json.cf
, using the bnfc language, and documented in bnfc/Json.pdf
(which is produced by
make bnfc
).
The library provides simple lookup methods, akin to Xpath for XML. Using these, one can extract the value (scalar or array) of any component inside a CSON data structure, named as a path (list) of field names.
Some example data files are provided in examples/
, and the test file test-get-path.cc
, compiled to get-path
,
provides usage examples.
examples/data-nested.cjs
, and several lookups from it using get-path
.
{ a = 1,
b = 2,
c = [ {x={aa=1, ab=4}, y=2},
{x={aa=3, ab=8}, y=12}
],
d = { a = 23, b = 25 }
e = [ 1, 2, 3, 4 ]
}
$ ./get-path d b < examples/data-nested.cjs
scalar:25
$ ./get-path c < examples/data-nested.cjs
list: (1,4,2) (3,8,12) $