From afa1c55fbd81c7c3e627c620dd52422d64be378d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 16 Feb 2011 00:24:52 +0000 Subject: add jshn (JSON SHell Notation), a small utility and shell library for parsing and generating json data git-svn-id: svn://svn.openwrt.org/openwrt/trunk@25547 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/jshn/example.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 package/jshn/example.txt (limited to 'package/jshn/example.txt') diff --git a/package/jshn/example.txt b/package/jshn/example.txt new file mode 100644 index 0000000000..d5ab1c4d23 --- /dev/null +++ b/package/jshn/example.txt @@ -0,0 +1,19 @@ +. /lib/functions/jshn.sh + +# generating json data +json_init +json_add_string "msg" "Hello, world!" +json_add_object "test" +json_add_int "testdata" "1" +json_close_object +MSG=`json_dump` +# MSG now contains: { "msg": "Hello, world!", "test": { "testdata": 1 } } + + +# parsing json data +json_load "$MSG" +json_select test +json_get_var var1 testdata +json_select .. +json_get_var var2 msg +echo "msg: $var2 - testdata: $var1" -- cgit v1.2.3