add jshn (JSON SHell Notation), a small utility and shell library for parsing and...
[openwrt.git] / package / jshn / example.txt
diff --git a/package/jshn/example.txt b/package/jshn/example.txt
new file mode 100644 (file)
index 0000000..d5ab1c4
--- /dev/null
@@ -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"
This page took 0.023917 seconds and 4 git commands to generate.