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条)

报告相同问题?