I have the following json data
{
"apps": [
{
"thingA": "aaaaaa",
"thingB": "bbbbbb",
"thingC": "cccccc",
"thingD": {
"thingD1": "d1d1d1d1",
"thingD2": "d2d2d2d2"
},
"thingE": "eeeeee",
"out_file": "ffffff"
},
{
"thingA": "aaaaaa",
"thingB": "bbbbbb",
"thingC": "cccccc",
"thingD": {
"thingD1": "d1d1d1d1",
"thingD2": "d2d2d2d2"
},
"thingE": "eeeeee",
"out_file": "ffffff"
},
{
"thingA": "aaaaaa",
"thingB": "bbbbbb",
"thingC": "cccccc",
"thingD": {
"thingD1": "d1d1d1d1",
"thingD2": "d2d2d2d2"
},
"thingE": "eeeeee",
"out_file": "ffffff"
}
]
}
I'm attempting to convert this to an array in PHP using json_decode, remove an item from the array based on the array position / index, then convert the array back to JSON using json_encode.
To modify the array, im using the following PHP command
unset($configuration_Array->{'apps'}[$i]);
Where $i is the index position of the item being removed.
it's all working almost perfectly except that in the final (output) JSON data, I noticed I get key values added to each "apps" object (note the 'number key before each object')
{
"apps":{
"1":{
"thingA":"aaaaaa",
"thingB":"bbbbbb",
"thingC":"cccccc",
"thingD":{
"thingD1":"d1d1d1d1",
"thingD2":"d2d2d2d2"
},
"thingE":"eeeeee",
"out_file":"ffffff"
},
"2":{
"thingA":"aaaaaa",
"thingB":"bbbbbb",
"thingC":"cccccc",
"thingD":{
"thingD1":"d1d1d1d1",
"thingD2":"d2d2d2d2"
},
"thingE":"eeeeee",
"out_file":"ffffff"
},
"3":{
"thingA":"aaaaaa",
"thingB":"bbbbbb",
"thingC":"cccccc",
"thingD":{
"thingD1":"d1d1d1d1",
"thingD2":"d2d2d2d2"
},
"thingE":"eeeeee",
"out_file":"ffffff"
}
}
}
How can I avoid this being added when I perform json_encode or after the fact, remove it so that the data is structured exactly like the original version?