douzhao6584 2015-08-29 13:30
浏览 44

在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]
  • 写回答

1条回答 默认 最新

  • doudie2693 2015-08-29 14:02
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本