Created
May 2, 2015 06:32
-
-
Save milhomem/957b81e9f7f33ea15516 to your computer and use it in GitHub Desktop.
Diff two Json files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat /tmp/json_a | php -r '$f=file("php://stdin"); $a = json_decode(join($f), true); function ksortRecursive(&$array, $sort_flags = SORT_REGULAR) { if (!is_array($array)) return false; ksort($array, $sort_flags); foreach ($array as &$arr) { ksortRecursive($arr, $sort_flags); } return true; }; ksortRecursive($a); echo var_export($a,true);' > /tmp/json_a_sorted | |
cat /tmp/json_b | php -r '$f=file("php://stdin"); $a = json_decode(join($f), true); function ksortRecursive(&$array, $sort_flags = SORT_REGULAR) { if (!is_array($array)) return false; ksort($array, $sort_flags); foreach ($array as &$arr) { ksortRecursive($arr, $sort_flags); } return true; }; ksortRecursive($a); echo var_export($a,true);' > /tmp/json_b_sorted | |
diff /tmp/json_a_sorted /tmp/json_b_sorted -u --ignore-all-space |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment