Elektra
0.8.25
|
This is a plugin reading and writing JSON files using the library yail
The plugin was tested with yajl version 1.0.8-1 from Debian 6 and yajl version 2.0.4-2 from Debian 7.
Examples of files which are used for testing can be found below the folder in "src/plugins/yajl/yajl".
The JSON grammar can be found here.
A validator can be found here.
Supports every KeySet except when arrays are intermixed with other keys. Has only limited support for metadata.
libyajl-dev
(version 1 and 2 should work)The type of the data is available via the metadata type
:
string
: The JSON string type.boolean
: The JSON boolean type (true or false)double
: For JSON numbers.If no metadata type
is given, the type is either:
null
on binary null-keystring
otherwiseAny other type/value will still be treated as string, but the warning #78
will be added because of the potential data loss.
In JSON it is possible to have empty arrays and objects. In Elektra this is mapped using the special names
###empty_array
and
___empty_map
Arrays are mapped to Elektra’s array convention #0, #1,..
iconv
plugin if your locale are not UTF-8. When using non-UTF-8 the plugin will be able to write the file, but cannot parse it back again. You will error #77, invalid bytes in UTF8 string.Because of these potential problems a type checker and comments filter are highly recommended.
The following example shows you how you can read and write data using this plugin.
`` <h1>Mount the plugin to the cascading namespace
/tests/yajl` sudo kdb mount config.json /tests/yajl yajl
printf '{ "number": 1337 }' > kdb file /tests/yajl
kdb get /tests/yajl/number #> 1337
kdb getmeta /tests/yajl/number type #> double
kdb set /tests/yajl/key value #> Using name user/tests/yajl/key #> Create a new key user/tests/yajl/key with string "value"
kdb get /tests/yajl/key #> value
user/tests/yajl/
).kdb file user/tests/yajl/ | xargs cat #> { #> "___dirdata": "", #> "key": "value", #> "number": 1337 #> }
kdb set user/tests/yajl/piggy/#0 straw kdb set user/tests/yajl/piggy/#1 sticks kdb set user/tests/yajl/piggy/#2 bricks
kdb get user/tests/yajl/piggy/#2 #> bricks
kdb file user/tests/yajl | xargs cat #> { #> "___dirdata": "", #> "key": "value", #> "number": 1337, #> "piggy": [ #> "___dirdata: ", #> "straw", #> "sticks", #> "bricks" #> ] #> }
kdb rm -r /tests/yajl sudo kdb umount /tests/yajl
/tests/yajl
sudo kdb mount config.json /tests/yajl yajl
kdb set /tests/yajl/roots 'Things Fall Apart' kdb set /tests/yajl/roots/bloody 'Radical Face' kdb set /tests/yajl/roots/bloody/roots 'No Roots'
kdb set /tests/yajl/now ', Now' kdb set /tests/yajl/now/#0 'Neighbors' kdb set /tests/yajl/now/#1 'Threads'
kdb ls /tests/yajl #> user/tests/yajl #> user/tests/yajl/now #> user/tests/yajl/now/#0 #> user/tests/yajl/now/#1 #> user/tests/yajl/roots #> user/tests/yajl/roots/bloody #> user/tests/yajl/roots/bloody/roots
kdb get /tests/yajl/roots #> Things Fall Apart kdb get /tests/yajl/roots/bloody #> Radical Face
kdb get /tests/yajl/roots/bloody/roots #> No Roots
kdb get /tests/yajl/now #> , Now kdb getmeta /tests/yajl/now array #> #1 kdb get /tests/yajl/now/#0 #> Neighbors kdb get /tests/yajl/now/#1 #> Threads
kdb rm -r /tests/yajl sudo kdb umount /tests/yajl
or:
Then you can copy the OpenICC_device_config_DB.json
to systemwide or user config, e.g.
prints out then all device entries available in the config
prints out "Glasshuette" with the example config in source
You can export the whole system openicc config to ini with:
or import it: