https://github.com/mevdschee/json_sort.php
Sort a json string so that you can compare it using string comparison
https://github.com/mevdschee/json_sort.php
Last synced: 8 months ago
JSON representation
Sort a json string so that you can compare it using string comparison
- Host: GitHub
- URL: https://github.com/mevdschee/json_sort.php
- Owner: mevdschee
- License: mit
- Created: 2019-10-27T19:38:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-28T07:44:34.000Z (about 6 years ago)
- Last Synced: 2025-05-08T23:48:37.311Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json_sort.php
Have you ever tried to write unit tests for JSON output? Did you run into the "unordered" nature of JSON
in accordance with [RFC 7159](https://tools.ietf.org/html/rfc7159)? If so, this repo is for you!
It provides a single method that parses the JSON and reproduces it sorted in Lexicographical order.
It has no dependencies (other than json support in PHP) and is a single method. No path matching or PHPUnit required.
[Show me the code!](json_sort.php)
NB: If you do use PHPUnit, then take a look at the "`assertJsonStringEqualsJsonString`" function [here](https://phpunit.readthedocs.io/en/latest/assertions.html#assertjsonstringequalsjsonstring).