I was working on JSON data. I want to know is there any library which can help me to compare JSON .
example:
Json 1:
[{“Mcast”:“xyz”,“Source”:“10.11.1.33”},{“Cmts”:“pqr”,“Source”:“10.11.1.33”},{“Rpd”:“11:30:10:11:11:a1”,“sinks”:""},{“Mcast”:“xyz”,“Source”:“10.11.1.32”}]
Json 2:
[{“Rpd”:“11:30:10:11:11:a1”,“sinks”:""},{“Mcast”:“xyz”,“Source”:“10.11.1.33”},{“Cmts”:“pqr”,“Source”:“10.11.1.33”},{“Mcast”:“xyz”,“Source”:“10.11.1.32”}]
Both the JSON are the same, just the index of the objects are different.
No, the JSONs are different, as in a list order matters.
If your definition of equality is different, you need to implement that on your own.
In go-loke pseudo code it would roughly look like this:
func is_permutation([]map[string]string a, b) bool {
for _, v := range a {
if is_member(v, b) {
delete_element(v, b)
} else {
return false
}
}
return true
}