Skip to content

Instantly share code, notes, and snippets.

@CDRussell
Created July 21, 2015 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CDRussell/2bde5d6f6924a5c16e69 to your computer and use it in GitHub Desktop.
Save CDRussell/2bde5d6f6924a5c16e69 to your computer and use it in GitHub Desktop.
Asserts that two Strings containing JSON are equal.
public static void assertEqualsJson(String expected, String actual) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
assertEquals(objectMapper.readTree(expected), objectMapper.readTree(actual));
}
@CDRussell
Copy link
Author

Equality means that the keys and values are equal; this deliberately ignores comparing whitespace and order of elements.

Requires com.fasterxml.jackson.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment