doutuo7156 2012-09-23 09:59 采纳率: 100%
浏览 68
已采纳

如何将URL编码的JSON数组转换为PHP数组

how can convert URL encoded JSON sent from my android application into PHP array.Current format i am getting looks like below format.

[{\\\"product_id\\\":\\\"33\\\",\\\"amount\\\":\\\"1\\\"},{\\\"product_id\\\":\\\"34\\\",\\\"amount\\\":\\\"3\\\"},{\\\"product_id\\\":\\\"10\\\",\\\"amount\\\":\\\"1\\\"}]

How can i convert those data into below format


product_id    amount
   33         1 
   34         3 
   10         1 

Because i want to insert those data into MySQL database.Can anyone please help me regarding this problem.

  • 写回答

3条回答 默认 最新

  • douang1243 2012-09-23 10:14
    关注

    json_decode(jsonencoded string, TRUE) is correct way to encode json string.

    But your json string encoded too deeper and recursive. your json encode string should as below

    [{"product_id":9,"amount":500},{"product_id":9,"amount":500},{"product_id":9,"amount":500}]
    

    Other wise, you will get NULL value

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug