|
@@ -9,12 +9,20 @@ check usage:
|
|
|
Usage: jshn [-n] [-i] -r <message>|-R <file>|-o <file>|-p <prefix>|-w
|
|
|
[2]
|
|
|
|
|
|
+ $ jshn-san
|
|
|
+ Usage: jshn-san [-n] [-i] -r <message>|-R <file>|-o <file>|-p <prefix>|-w
|
|
|
+ [2]
|
|
|
+
|
|
|
test bad json:
|
|
|
|
|
|
$ jshn -r '[]'
|
|
|
Failed to parse message data
|
|
|
[1]
|
|
|
|
|
|
+ $ jshn-san -r '[]'
|
|
|
+ Failed to parse message data
|
|
|
+ [1]
|
|
|
+
|
|
|
test good json:
|
|
|
|
|
|
$ jshn -r '{"foo": "bar", "baz": {"next": "meep"}}'
|
|
@@ -24,16 +32,31 @@ test good json:
|
|
|
json_add_string 'next' 'meep';
|
|
|
json_close_object;
|
|
|
|
|
|
+ $ jshn-san -r '{"foo": "bar", "baz": {"next": "meep"}}'
|
|
|
+ json_init;
|
|
|
+ json_add_string 'foo' 'bar';
|
|
|
+ json_add_object 'baz';
|
|
|
+ json_add_string 'next' 'meep';
|
|
|
+ json_close_object;
|
|
|
+
|
|
|
test json from file:
|
|
|
|
|
|
$ echo '[]' > test.json; jshn -R test.json
|
|
|
Failed to parse message data
|
|
|
[1]
|
|
|
|
|
|
+ $ echo '[]' > test.json; jshn-san -R test.json
|
|
|
+ Failed to parse message data
|
|
|
+ [1]
|
|
|
+
|
|
|
$ jshn -R nada.json
|
|
|
Error opening nada.json
|
|
|
[3]
|
|
|
|
|
|
+ $ jshn-san -R nada.json
|
|
|
+ Error opening nada.json
|
|
|
+ [3]
|
|
|
+
|
|
|
$ echo '{"foo": "bar", "baz": {"next": "meep"}}' > test.json; jshn -R test.json
|
|
|
json_init;
|
|
|
json_add_string 'foo' 'bar';
|
|
@@ -41,38 +64,74 @@ test json from file:
|
|
|
json_add_string 'next' 'meep';
|
|
|
json_close_object;
|
|
|
|
|
|
+ $ echo '{"foo": "bar", "baz": {"next": "meep"}}' > test.json; jshn-san -R test.json
|
|
|
+ json_init;
|
|
|
+ json_add_string 'foo' 'bar';
|
|
|
+ json_add_object 'baz';
|
|
|
+ json_add_string 'next' 'meep';
|
|
|
+ json_close_object;
|
|
|
+
|
|
|
test json formatting without prepared environment:
|
|
|
|
|
|
$ jshn -p procd -w
|
|
|
{ }
|
|
|
|
|
|
+ $ jshn-san -p procd -w
|
|
|
+ { }
|
|
|
+
|
|
|
$ jshn -i -p procd -w
|
|
|
{
|
|
|
\t (esc)
|
|
|
}
|
|
|
|
|
|
+ $ jshn-san -i -p procd -w
|
|
|
+ {
|
|
|
+ \t (esc)
|
|
|
+ }
|
|
|
+
|
|
|
$ jshn -i -n -p procd -w
|
|
|
{
|
|
|
\t (esc)
|
|
|
} (no-eol)
|
|
|
|
|
|
+ $ jshn-san -i -n -p procd -w
|
|
|
+ {
|
|
|
+ \t (esc)
|
|
|
+ } (no-eol)
|
|
|
+
|
|
|
$ jshn -p procd -o test.json; cat test.json
|
|
|
{ }
|
|
|
|
|
|
+ $ jshn-san -p procd -o test.json; cat test.json
|
|
|
+ { }
|
|
|
+
|
|
|
$ jshn -i -p procd -o test.json; cat test.json
|
|
|
{
|
|
|
\t (esc)
|
|
|
}
|
|
|
|
|
|
+ $ jshn-san -i -p procd -o test.json; cat test.json
|
|
|
+ {
|
|
|
+ \t (esc)
|
|
|
+ }
|
|
|
+
|
|
|
$ jshn -i -n -p procd -o test.json; cat test.json
|
|
|
{
|
|
|
\t (esc)
|
|
|
} (no-eol)
|
|
|
|
|
|
+ $ jshn-san -i -n -p procd -o test.json; cat test.json
|
|
|
+ {
|
|
|
+ \t (esc)
|
|
|
+ } (no-eol)
|
|
|
+
|
|
|
$ chmod oug= test.json
|
|
|
$ jshn -i -n -p procd -o test.json
|
|
|
Error opening test.json
|
|
|
[3]
|
|
|
+ $ jshn-san -i -n -p procd -o test.json
|
|
|
+ Error opening test.json
|
|
|
+ [3]
|
|
|
$ rm -f test.json
|
|
|
|
|
|
test json formatting with prepared environment:
|
|
@@ -104,6 +163,9 @@ test json formatting with prepared environment:
|
|
|
$ jshn -p procd -w
|
|
|
{ "name": "urngd", "script": "\/etc\/init.d\/urngd", "instances": { "instance1": { "command": [ "\/sbin\/urngd" ] } }, "triggers": [ ], "data": { } }
|
|
|
|
|
|
+ $ jshn-san -p procd -w
|
|
|
+ { "name": "urngd", "script": "\/etc\/init.d\/urngd", "instances": { "instance1": { "command": [ "\/sbin\/urngd" ] } }, "triggers": [ ], "data": { } }
|
|
|
+
|
|
|
$ jshn -i -p procd -w
|
|
|
{
|
|
|
\t"name": "urngd", (esc)
|
|
@@ -123,6 +185,25 @@ test json formatting with prepared environment:
|
|
|
\t} (esc)
|
|
|
}
|
|
|
|
|
|
+ $ jshn-san -i -p procd -w
|
|
|
+ {
|
|
|
+ \t"name": "urngd", (esc)
|
|
|
+ \t"script": "/etc/init.d/urngd", (esc)
|
|
|
+ \t"instances": { (esc)
|
|
|
+ \t\t"instance1": { (esc)
|
|
|
+ \t\t\t"command": [ (esc)
|
|
|
+ \t\t\t\t"/sbin/urngd" (esc)
|
|
|
+ \t\t\t] (esc)
|
|
|
+ \t\t} (esc)
|
|
|
+ \t}, (esc)
|
|
|
+ \t"triggers": [ (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t], (esc)
|
|
|
+ \t"data": { (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t} (esc)
|
|
|
+ }
|
|
|
+
|
|
|
$ jshn -n -i -p procd -w
|
|
|
{
|
|
|
\t"name": "urngd", (esc)
|
|
@@ -142,9 +223,31 @@ test json formatting with prepared environment:
|
|
|
\t} (esc)
|
|
|
} (no-eol)
|
|
|
|
|
|
+ $ jshn-san -n -i -p procd -w
|
|
|
+ {
|
|
|
+ \t"name": "urngd", (esc)
|
|
|
+ \t"script": "/etc/init.d/urngd", (esc)
|
|
|
+ \t"instances": { (esc)
|
|
|
+ \t\t"instance1": { (esc)
|
|
|
+ \t\t\t"command": [ (esc)
|
|
|
+ \t\t\t\t"/sbin/urngd" (esc)
|
|
|
+ \t\t\t] (esc)
|
|
|
+ \t\t} (esc)
|
|
|
+ \t}, (esc)
|
|
|
+ \t"triggers": [ (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t], (esc)
|
|
|
+ \t"data": { (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t} (esc)
|
|
|
+ } (no-eol)
|
|
|
+
|
|
|
$ jshn -p procd -o test.json; cat test.json
|
|
|
{ "name": "urngd", "script": "\/etc\/init.d\/urngd", "instances": { "instance1": { "command": [ "\/sbin\/urngd" ] } }, "triggers": [ ], "data": { } }
|
|
|
|
|
|
+ $ jshn-san -p procd -o test.json; cat test.json
|
|
|
+ { "name": "urngd", "script": "\/etc\/init.d\/urngd", "instances": { "instance1": { "command": [ "\/sbin\/urngd" ] } }, "triggers": [ ], "data": { } }
|
|
|
+
|
|
|
$ jshn -i -p procd -o test.json; cat test.json
|
|
|
{
|
|
|
\t"name": "urngd", (esc)
|
|
@@ -164,6 +267,25 @@ test json formatting with prepared environment:
|
|
|
\t} (esc)
|
|
|
}
|
|
|
|
|
|
+ $ jshn-san -i -p procd -o test.json; cat test.json
|
|
|
+ {
|
|
|
+ \t"name": "urngd", (esc)
|
|
|
+ \t"script": "/etc/init.d/urngd", (esc)
|
|
|
+ \t"instances": { (esc)
|
|
|
+ \t\t"instance1": { (esc)
|
|
|
+ \t\t\t"command": [ (esc)
|
|
|
+ \t\t\t\t"/sbin/urngd" (esc)
|
|
|
+ \t\t\t] (esc)
|
|
|
+ \t\t} (esc)
|
|
|
+ \t}, (esc)
|
|
|
+ \t"triggers": [ (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t], (esc)
|
|
|
+ \t"data": { (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t} (esc)
|
|
|
+ }
|
|
|
+
|
|
|
$ jshn -n -i -p procd -o test.json; cat test.json
|
|
|
{
|
|
|
\t"name": "urngd", (esc)
|
|
@@ -183,7 +305,29 @@ test json formatting with prepared environment:
|
|
|
\t} (esc)
|
|
|
} (no-eol)
|
|
|
|
|
|
+ $ jshn-san -n -i -p procd -o test.json; cat test.json
|
|
|
+ {
|
|
|
+ \t"name": "urngd", (esc)
|
|
|
+ \t"script": "/etc/init.d/urngd", (esc)
|
|
|
+ \t"instances": { (esc)
|
|
|
+ \t\t"instance1": { (esc)
|
|
|
+ \t\t\t"command": [ (esc)
|
|
|
+ \t\t\t\t"/sbin/urngd" (esc)
|
|
|
+ \t\t\t] (esc)
|
|
|
+ \t\t} (esc)
|
|
|
+ \t}, (esc)
|
|
|
+ \t"triggers": [ (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t], (esc)
|
|
|
+ \t"data": { (esc)
|
|
|
+ \t\t (esc)
|
|
|
+ \t} (esc)
|
|
|
+ } (no-eol)
|
|
|
+
|
|
|
$ chmod oug= test.json
|
|
|
$ jshn -n -i -p procd -o test.json
|
|
|
Error opening test.json
|
|
|
[3]
|
|
|
+ $ jshn-san -n -i -p procd -o test.json
|
|
|
+ Error opening test.json
|
|
|
+ [3]
|