Given the following json:
{
"project": "AndroidApp1",
"build": {
"platform": "Android",
"type": "App",
"signing": {
"pipeline-supported": false,
"keystore": "release.jks",
"keystore.properties": ""
}
},
"automation":{
"feature.automation.behaviour": "off",
"feature.automation.branches": [
{
"branch": "feature-branch-name-1",
"automation": true,
"publish-fabric": false,
"publish-ftp": false,
"version-code": 19227
},
{
"branch": "feature-branch-name-2"
}
]
}
}
I created the following function that can read a value from the json:
function readBuildConfigValue(){
if [ -e cicd.json ]
then
jsonvalue=`cat cicd.json | python -c "import json; import sys; data=json.load(sys.stdin); print data['$1']"`
echo $jsonvalue
else
echo ""
fi
}
So if I do project=$(readBuildConfigValue "project")
the project variable would be AndroidApp1 which is what is expected.
How can I then modify this function to return the json in such a way that I can in the shell script do something like keystore=jsondata['build']['signing']['keystore']