From 5e326f51c58e500285ea3daee91986ee1ea518eb Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 Nov 2013 13:24:42 +0100 Subject: sandbox -> .graveyard --- sandbox/json/sh/json.sh | 116 ---------------------------------------------- sandbox/json/sh/test.json | 7 --- 2 files changed, 123 deletions(-) delete mode 100755 sandbox/json/sh/json.sh delete mode 100644 sandbox/json/sh/test.json (limited to 'sandbox/json') diff --git a/sandbox/json/sh/json.sh b/sandbox/json/sh/json.sh deleted file mode 100755 index 79f8529a..00000000 --- a/sandbox/json/sh/json.sh +++ /dev/null @@ -1,116 +0,0 @@ -#! /bin/sh -set -euf - -# TODO check json first - -# XXX json_key is something like PWD^^ - -normalize_json() { - sed -n ' - 1s/^/cat<&2 - 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 -n "s/^\(${json_key}_[a-zA-Z]\+\)=\(.*\)/\1/p"`" -} -begin_json_array() { :; } -end_json_array() { :; } -json_push_key() { - push_key "`echo -n "$1" | base64 -d`" -} -json_set_key() { - pop_key - json_push_key "$1" -} -json_set() { - ##echo "typeof_$json_key=$1" >&2 - ##echo "${json_key}_VALUE=\"$2\"" >&2 # (`echo -n $2 | base64 -d`)" >&2 - #eval "${json_key}_TYPE=$1" - #eval "${json_key}_VALUE=\"$2\"" - eval "typeof_${json_key}=$1" - eval "${json_key}=\"$2\"" -} - -push_key() { - json_key="${json_key+${json_key}_}$1" -} -pop_key() { - json_key="`echo $json_key | sed 's/_[^_]\+$//'`" -} - -json() { - #eval echo "\"\$`echo -n "$json_key" "$@" | tr "$IFS" _`\" | base64 -d" - NAME="`echo -n "$json_key" "$@" | tr "$IFS" _`" - #eval "TYPE=\"\$${NAME}_TYPE\"" - eval "TYPE=\"\$typeof_$NAME\"" - - echo -n "$TYPE $NAME: " - case "$TYPE" in - (object) - #eval echo -n \$${NAME}_VALUE - eval echo -n \$$NAME - ;; - #set | sed -rn "s/^(${NAME})_([a-zA-Z]+)[a-zA-Z_]*_VALUE=(.*)/\1_\2/p" | - # sort | uniq | tr \\n \ ;; - (*) #echo -n "$VALUE";; - #eval "VALUE=\"\$(echo -n \"\$${NAME}_VALUE\" | base64 -d)\"" - #eval echo -n \"\$${NAME}_VALUE\" | base64 -d - eval echo -n \$${NAME} | base64 -d - esac - echo -} - -read_json() { - json_key="${1-JSON}" - #meh="`cat`" - #echo "$meh" - ##echo "$meh" | normalize_json | json_to_sh; exit - #eval "`echo "$meh" | normalize_json | json_to_sh`" - eval "`normalize_json | json_to_sh`" -} - -# TODO print_json x, print_json x ca ... to print as json - -read_json "$1" -echo ==== -set | egrep "^(typeof_)?$json_key[A-Za-z_]*=" -echo ==== -json -json a -json b -json c -json c ca -json c cb -json d -#echo ==== -#echo $JSON_VALUE -#echo $JSON_c_cb_VALUE | base64 -d; echo - -echo READY. -#### End of file. diff --git a/sandbox/json/sh/test.json b/sandbox/json/sh/test.json deleted file mode 100644 index 9b4c6312..00000000 --- a/sandbox/json/sh/test.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "a": "1", - "b": 2, - "c": { "ca": 11, "cb": [1, 2, 3, "42"] }, - "d": {}, - "float": 4.23 -} -- cgit v1.2.3