examples: add example code for json_script.
[project/libubox.git] / examples / json_script-example.json
diff --git a/examples/json_script-example.json b/examples/json_script-example.json
new file mode 100644 (file)
index 0000000..45636b7
--- /dev/null
@@ -0,0 +1,33 @@
+[
+  [ "exec", "%EXECVAR%", "/%%/" ],
+  [ "if",
+    [ "eq", "EQVAR", "eqval" ],
+    [ "exec_if", "%VAR%", "%%", "jk" ]
+  ],
+  [ "case", "CASEVAR", {
+    "caseval0": ["cmd_case_0", "cmd_case_arg0", "case_cmd_arg1"],
+    "caseval1": ["cmd_case_1", "cmd_case_arg0", "case_cmd_arg1"]
+  } ],
+
+  [ "if",
+    [ "and", [ "eq", "EQVAR", "eqval" ],
+             [ "has", "HASVAR" ],
+             [ "regex", "REGEXVAR0", "regexval" ],
+             [ "regex", "REGEXVAR1", [ "regexval10", "regexval11" ] ],
+             [ "not", [ "eq", "NOTEQVAR", "noteqval" ] ] ],
+    [ "exec_if_and", "%ANDVAR%" ]
+  ],
+
+  [ "if",
+    [ "or", [ "eq", "EQVAR", "eqval" ],
+            [ "has", "HASVAR" ],
+            [ "regex", "REGEXVAR0", "regexval" ],
+            [ "regex", "REGEXVAR1", [ "regexval10", "regexval11" ] ],
+            [ "not", [ "eq", "NOTEQVAR", "noteqval" ] ] ],
+    [ "exec_if_or", "%ORVAR%" ]
+  ],
+
+  [ "return", "foobar" ],
+
+  [ "exec_non_reachable", "Arghhh" ]
+]