summaryrefslogtreecommitdiffstats
path: root/package/jshn/example.txt
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-02-16 00:24:52 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-02-16 00:24:52 +0000
commit3b96f8e26b0fa34da206538181593dfdf16e4a54 (patch)
tree8833da94020531981dc723a4e28ea29f64f0df9d /package/jshn/example.txt
parent200663f5d96c38484074fcb2849aae126dc6fb7f (diff)
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
Diffstat (limited to 'package/jshn/example.txt')
-rw-r--r--package/jshn/example.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/package/jshn/example.txt b/package/jshn/example.txt
new file mode 100644
index 000000000..d5ab1c4d2
--- /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"