在PHP脚本上恢复JSON

I have JSON -

{"First name": "John", "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