How to reverse a json file?
json
Solution
Try this:
<?php
$str=<<<EOT
{
"name 1" : "value 1",
"name 2" : "value 2"
}
EOT;
echo json_encode(array_flip(json_decode($str,true)));
?>
Output: `{"value 1":"name 1","value 2":"name 2"}`
Problem
I want to reverse a JSON file ( with php, python, java or other solutions :) ) From : ``` { "name 1" : "value 1", "name 2" : "value 2" } ``` To : ``` { "value 1" : "name 1", "value 2" : "name 2" } ``` Ideas ? :) Thank you !