开发者

Revert JSON on php script

开发者 https://www.devze.com 2023-03-15 06:54 出处:网络
I have JSON - {\"First name\": \"Jo开发者_开发百科hn\", \"Contact\": \"2323\",...} with arbitrary number of key/value pairs. My $.ajax-function sends JSON to a php script. The PHP script must reve

I have JSON -

{"First name": "Jo开发者_开发百科hn", "Contact": "2323",...}

with arbitrary number of key/value pairs. My $.ajax-function sends JSON to a php script. The PHP script must revert JSON and back to jQuery.

{"John": "First name", "2323": "Contact",...}

PHP code for this iteration and jQuery handling code for response?


PHP json_decode() then array_reverse and json_encode()

In jQuery get data by .ajax with dataType: 'json' and array will be ready to use.

I think that application logic shouldn't rely on array elements order

0

精彩评论

暂无评论...
验证码 换一张
取 消