diff options
author | makefu <github@syntax-fehler.de> | 2011-09-12 14:32:18 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2011-09-12 14:32:18 +0200 |
commit | 9f70f9b5b462aa3e150b9708f695edfaf716edd4 (patch) | |
tree | 5cbebe6cbc0ada2c988d7f14d0bbbc52a68b37c1 /json | |
parent | 568fbd7fa5541182bbbc33560863ec9c3ff01d48 (diff) | |
parent | a07326f6c57a7e8f49b9bef96ded427275a16e2e (diff) |
Merge branch 'master' into punani_files
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() { :; } |