diff options
author | root <root@krebs> | 2011-09-09 18:20:34 +0200 |
---|---|---|
committer | root <root@krebs> | 2011-09-09 18:20:34 +0200 |
commit | 176c9ac08ad9c2ddc430b2d1a194f6be41115f5b (patch) | |
tree | 82ea214ff1d45799099576e4ff007c34a6b7c990 /json | |
parent | dac9eb2553987778500e0bc7e54ad2a28124969d (diff) | |
parent | 150ce5757d2982da740bd9ce2b44b57b6d2831c6 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'json')
-rwxr-xr-x | json/sh/json.sh | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/json/sh/json.sh b/json/sh/json.sh index 2a64d371..79f8529a 100755 --- a/json/sh/json.sh +++ b/json/sh/json.sh @@ -6,23 +6,23 @@ set -euf # XXX json_key is something like PWD^^ normalize_json() { - sed -rn ' + sed -n ' 1s/^/cat<<EOF\n/ # TODO handle escaped double quotes - s/"[^"]+"/"$(echo -n & | base64)"/g + s/"[^"]\+"/"$(echo -n & | base64)"/g $s/$/\nEOF/ p ' | sh | tr -d '[:space:]' } json_to_sh() { - sed -rn ' + sed -n ' s/,/;/g s/\[/begin_json_array;/g; s/\]/end_json_array;/g s/\{/begin_json_object;/g; s/\}/end_json_object;/g - s/("[^"]+"):/json_set_key \1;/g - s/;("[^"]+")/;json_set string \1;/g - s/;([0-9.]+)/;json_set number `echo -n \1 | base64`;/g + s/\("[^"]\+"\):/json_set_key \1;/g + s/;\("[^"]\+"\)/;json_set string \1;/g + s/;\([0-9.]\+\)/;json_set number `echo -n \1 | base64`;/g s/;;/;/g s/;/\n/g p @@ -37,7 +37,7 @@ end_json_object() { pop_key # TODO check if is %%%MAKEJSONOBJ%%% #echo obj: $1 `set | sed -rn "s/^(${json_key}_[a-zA-Z]+)_VALUE=(.*)/\1/p"` >&2 #json_set object "`set | sed -rn "s/^(${json_key}_[a-zA-Z]+)_VALUE=(.*)/\1/p"`" - json_set object "`set | sed -rn "s/^(${json_key}_[a-zA-Z]+)=(.*)/\1/p"`" + json_set object "`set | sed -n "s/^\(${json_key}_[a-zA-Z]\+\)=\(.*\)/\1/p"`" } begin_json_array() { :; } end_json_array() { :; } |