I have a JSON like this
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
}
......
......
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
I want to iterate through each dictionary in images
array.
For that I wrote
declare -a images=($(cat Contents.json | jq ".images[]"))
for image in "${images[@]}"
do
echo "image --$image"
done
I am expecting output that each dictionary is printing in an iteration. That is
image --{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
}
image --{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@3x.png",
"scale" : "3x"
}
image --{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-Spotlight-40@2x.png",
"scale" : "2x"
}
Etc
But its iterating through each and every single elements in each dictionary like
image --{
image --"size":
image --"29x29",
image --"idiom":
image --"iphone",
image --"filename":
....
....
....
What is wrong with my code