-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return as environment variable #37
Comments
Not exactly what you're asking for, but I use the following two functions for extracting values from the JSON.sh output:
It expects the JSON.sh to be run with the Also, using |
So how about adding these to JSON.sh itself? That way you could source it, parse the json once and query away. |
Also, how would you get a list of keys in an object? |
Depends on the format you'd like. If the subset of JSON structure is OK for you, just use it without the |
Hi, I also was looking for a solution to "slurp" JSON.sh output into an bash array. source <( printf 'declare -A JSON=( %s )' "$(JSON.sh -s -b -n <input | sed -E -e 's/\t/=/g' -e 's#\\#\\\\#g')" ) this will be sourced "in place" as:
Now you can use bash array syntax to access the values:
In bashbot this makes parsing and assigning JSON five times faster In case you want to ask how to iterate over the array, see https://stackoverflow.com/questions/3112687/how-to-iterate-over-associative-arrays-in-bash |
i use JSON.sh as
curl 'http://conf.com/conf/config_20150920_test.json' | ./JSON.sh -l -p -b -s
and it work greet and it return result likebut what if add config param to determine how output look like and go with exporting this variables as env variables like
which make it easy to be evaluated with
eval
as environment variable.The text was updated successfully, but these errors were encountered: