I can´t figure out what is wrong with my code, I have a JSON which is structured this way
{
"data":[
{
"B00PM7UJMA":[
{
"Verkaufer":"Je Sens le Bonheur",
"Stock":71.0,
"Stock: Sold":7.0,
"Stock: Sold 30 Days":7.0,
"FBA":"no"
},
{
"Verkaufer":"Parfumea",
"Stock":2.0,
"Stock: Sold":"NaN",
"Stock: Sold 30 Days":"NaN",
"FBA":"no"
}
],
"Insgesamt":[
73.0
]
}
]
}
I am trying to access the "Data" but it won´t work at all. I can´t figure out what the problem is, maybe there is something going on with my JSON?
This is my PHP
$str = file_get_contents($row["URL"]);
$json = json_encode($str); // decode the JSON into an associative array
$jsondecode = json_decode($json, true);
print_r($jsondecode['data']); // doesn´t work at all
print_r($jsondecode->data); // doesn´t work either
Does someone know what the problem could be? I worked a lot with JSON via PHP. I bet the solution is really easy, but I just need someone others opinion on this one.
Thank you
$json = json_encode($str); // decode the JSON into an associative arrayIt isn't decoding bro. You are basically double encoding the string.$json = json_encode($str);, your string is already JSON.