Skip to content
Sort a json string so that you can compare it using string comparison
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
json_sort.php

README.md

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? 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!

NB: If you do use PHPUnit, then take a look at the "assertJsonStringEqualsJsonString" function here.

You can’t perform that action at this time.