Help editing JSON to make an array rather than a 'dictionary'

后端 未结 2 636
情书的邮戳
情书的邮戳 2020-12-12 04:57

I currently have json using json_encode from a mysql query which looks like this:

{\"post_2\":{\"caption\":\"...\",\"id\":\"...\",\"accountID\":\"..\",\"date         


        
相关标签:
2条回答
  • 2020-12-12 05:58

    Provide a non-associative array to json_encode(). The easiest way is usually to simply call array_values() on the (associative) array, and encode the result.

    0 讨论(0)
  • 2020-12-12 06:04

    Take a look at PHP's json_decode function, specifically the 2nd parameter if you want an array.

    0 讨论(0)
提交回复
热议问题