Version: v0.0.0-...-1dcaa55 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2016 License: MIT Imports: 3 Imported by: 0




Checks that two json strings (A and B) are compatible or not.

See the tests for examples as to how this works.

What is compatability?

If A has a field then the code expects B to have that same field with a value which corresponds to the same type. The code does not care about what actual data B or A has.

When it comes to arrays, B will need to have at least one item in it's own version so it can be proven it's compatible.

If B has extra fields they will still be seen as compatible.

Use cases

For help with implementing CDCs.

You can run this against a fake server and the real API you are using to ensure your test code and downstream services produce the JSON you need.



Package jsonequaliser tries to determine if two JSON strings (A and B) are compatible with each other in terms of having the same fields matched to the same types. It tries to reduce false negatives by ignoring extra fields in B and will only require evidence of compatability. For example if A has an array with 3 objects, B just needs one.



This section is empty.


This section is empty.


func ExampleIsCompatible

func ExampleIsCompatible()

ExampleIsCompatible shows how the JSON is compatible, even when the data is different. JSONEqualiser just checks the type of the fields

func ExampleIsIncompatible

func ExampleIsIncompatible()

ExampleIsIncompatible shows what happens when there is a problem. When consuming this lib you should check to see if the map is empty.

func IsCompatible

func IsCompatible(a, b string) (messages map[string]string, err error)

IsCompatible checks that two json strings are structurally the same so that they are compatible. The first string should be your "correct" json, if there are extra fields in B then they will still be seen as compatible


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL