Answer the question
In order to leave comments, you need to log in
How to remove keys?
Hello! Tell me, please:
When, for example, the method returns data in the form of json.
I will always have an array like this:
id: 0
type: 'car'
How can I pass it to js like this?
Now it comes in this:{id:0, type: 'car'}
[
{ id: 0, type: 'car'},
]
Answer the question
In order to leave comments, you need to log in
It's simple: {id:0, type: 'car'}
is the passed single object. [ { id: 0, type: 'car'} ]
is the passed array of objects.
If you want to pass an object, pass json_encode(Object)
.
If you want to pass an array, pass json_encode([Object1, Object2])
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question