aboutsummaryrefslogtreecommitdiffstats
path: root/package/jshn/example.txt
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-02-16 00:24:52 +0000
committerFelix Fietkau <nbd@openwrt.org>2011-02-16 00:24:52 +0000
commit9d4d2587d7ee0d76e1af0bc4e1889176ce209e04 (patch)
tree68cee38eae6a8a98a15cbce7b3a32f0ba20379a0 /package/jshn/example.txt
parentf1ac8cf2859bee611c5bba05a17f7ab0a2ebf5d0 (diff)
downloadupstream-9d4d2587d7ee0d76e1af0bc4e1889176ce209e04.tar.gz
upstream-9d4d2587d7ee0d76e1af0bc4e1889176ce209e04.tar.bz2
upstream-9d4d2587d7ee0d76e1af0bc4e1889176ce209e04.zip
add jshn (JSON SHell Notation), a small utility and shell library for parsing and generating json data
SVN-Revision: 25547
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 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"