Sample data:
{
"var_name1": {},
"var_name2": "string",
"var_name3": "long string",
"var_name4": 15
}
Fill Bash variable with extracted long string raw value from JSON:
VAR_NAME=`cat file.json | jq --raw-output '.var_name3'`
Then reference "chunks" of data using Bash variable index modifiers, e.g. by 255 characters:
- ${VAR_NAME:0:255}
- ${VAR_NAME:255:255}
- ${VAR_NAME:510:255}
- ${VAR_NAME:765:255}
- ${VAR_NAME:1020:255}
VAR_NAME=`cat file.json | jq --raw-output '.var_name3'` ; echo $VAR_NAME ; echo ${VAR_NAME:0:255} ; echo ${VAR_NAME:255:255} ; echo ${VAR_NAME:510:255} ; echo ${VAR_NAME:765:255} ; echo ${VAR_NAME:1020:255}
Žiadne komentáre:
Zverejnenie komentára