A little utility for testing if 2 json strings are equal, for use in tests.
go run main.go '{"dog": 5, "cat": 3}' '{"cat":3, "dog": 5}'
- You may want to use a matcher library (like gomega) that has a function for this, since some of the other functionality in those libraries is pretty awesome
So the omega library uses this same approach:
https://github.com/onsi/gomega/blob/v1.0/matchers.go#L164
https://github.com/onsi/gomega/blob/v1.0/matchers/match_json_matcher.go#L15
The only difference is they marshall into an
interface{}
instead of amap[string]interface{}
so they can handle arrays too.I'm changing mine to use the same approach.