1 [ -z "$N" ] && .
/etc
/functions.sh
3 # functions for parsing and generating json
6 [ -n "$JSON_UNSET" ] && eval "unset $JSON_UNSET"
7 export -- JSON_SEQ
=0 JSON_STACK
= JSON_CUR
="JSON_VAR" JSON_UNSET
=
14 local cur
="${4:-$JSON_CUR}"
16 export ${NO_EXPORT:+-n} -- "${cur}_$var=$val"
17 export ${NO_EXPORT:+-n} -- "TYPE_${cur}_$var=$type"
18 append JSON_UNSET
"${cur}_$var TYPE_${cur}_$var"
19 append
"KEYS_${cur}" "$var"
23 JSON_SEQ
=$
(($JSON_SEQ + 1))
24 append JSON_STACK
"$JSON_CUR"
25 local table
="JSON_TABLE$JSON_SEQ"
26 export ${NO_EXPORT:+-n} -- "UP_$table=$JSON_CUR"
33 json_add_generic object
"$1" "$JSON_CUR" "$cur"
37 local oldstack
="$JSON_STACK"
38 export "KEYS_${JSON_CUR}"
39 JSON_CUR
="${JSON_STACK##* }"
40 JSON_STACK
="${JSON_STACK% *}"
41 [[ "$oldstack" == "$JSON_STACK" ]] && JSON_STACK
=
47 json_add_generic array
"$1" "$JSON_CUR" "$cur"
55 json_add_generic string
"$1" "$2"
59 json_add_generic int
"$1" "$2"
63 json_add_generic boolean
"$1" "$2"
66 # functions read access to json variables
79 eval "export ${NO_EXPORT:+-n} -- \"$dest=\${TYPE_${JSON_CUR}_$var}\""
85 eval "export ${NO_EXPORT:+-n} -- \"$dest=\${${JSON_CUR}_$var}\""
96 [[ "$1" == ".." ]] && {
97 eval "JSON_CUR=\"\${UP_$JSON_CUR}\""
100 json_get_type
type "$target"
103 json_get_var JSON_CUR
"$target"
106 echo "WARNING: Variable '$target' does not exist or is not an array/object"
This page took 0.048824 seconds and 5 git commands to generate.