I am parsing large json structures using json_decode() returning an object $obj. Within the object, it is necessary to replace some key/value pairs:
unset($obj->$oldkey);
$obj->$newkey = $newvalue;
Appearently, the new key/value pair will be appended at the end of object, while the old key/value pair is deleted from an abitrary position. How can I preserve the old order, i.e. a replacement at the same position?
EDIT: A possible solution may be to unset all keys and set all key/value pais new, but isn't there an easier way?