Possible Duplicate:
Unix command-line JSON parser?
If I have a config file in JSON and a PHP script to flatten the config file into something like this
database_dbname=sensei
database_password=somerandompassword
memcached_host=localhost
....
can I pipe this to my bash script and make each of the entry above as a variable?
./bin/flatten_config.php config.json | ./bin/my_bash_script.sh
so that in my bash-script I can use values from the config file
mysql -D${database_dbname} -p${database_password} ...
In bash
you could write in your script-file
source <(./bin/flatten_config.php config.json)
bash
will take the output of flatten_config.php
and parse it like input
Checkout TickTick.
It's a true Bash JSON parser.
#!/bin/bash
. /path/to/ticktick.sh
# File
DATA=`cat data.json`
# cURL
#DATA=`curl http://foobar3000.com/echo/request.json`
tickParse "$DATA"
echo ``pathname``
echo ``headers["user-agent"]``
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With