在JavaScript中将对象转换为PHP数组

When I console.log(myArray); it gives me structure below which I think is an object, I want to convert it into a fomrat{like json} that can be passed successfully via Ajax to PHP function

[Object, Object]
0: Object
color: some value
id: some value
img: some value
name: some value
price: some value
quantity: some value
total: some value
__proto__: Object
1: Object
color: "silver"
id: "3"
img: "Mobile-Huawei-MT7.jpg"
name: " Huawei Honor 6 - H60-L04"
price: "8171"
quantity: "1"
total: "8171"
__proto__: Object
length: 2
__proto__: Array[0]

The log you have is already that json structure.

See:

[Object Object]

In this log you can see there are two objects in the array. In your log I can see you have some key value pairs.

So this

{key : value}

This is the actual object in the array.

I would say, the log you have is an array which has two objects which is as said above a key value pairs.

[Object Object]

The above one is just a log representation. Actual Object looks like {} which can have multiple key value pairs.