php - Trying to get property 'categories' of non-object in
Get the solution ↓↓↓I am using json parsing in Php. i am getting all json data but ii gives error as below.
Notice: Trying to get property 'categories' of non-object in
My codes as below
$json_url = "https://api.trendyol.com/sapigw/product-categories";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
var_dump($data[0]->categories->name[0]);
Example Json as below.
{
"categories": [
{
"id": 368,
"name": "Aksesuar"
},
{
"id": 368,
"name": "Aksesuar"
}
]}
Answer
Solution:
You are using json_decode and trying to use a flag TRUE as a second param.
$data = json_decode($json, TRUE);
- you will get a multiply array where$data[0]
- 'categories' and 'categories' got 2 elements which are an arrays.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illuminate\http\exceptions\posttoolargeexception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.