If there is an uncertainty in the order of the fields then I would suggest you to use Hamcrest Matchers

You have not posted the responses so I can only give you examples

body(containsString("Hello World"));

or you could also try something like the below

body("find { it.userId == '123' }.subject", containsInAnyOrder("MATHS", "SCIENCE"))
Answer from Wilfred Clement on Stack Overflow
🌐
Makeseleniumeasy
makeseleniumeasy.com › 2021 › 05 › 14 › rest-assured-tutorial-72-how-to-compare-part-of-json-objects-and-arrays-using-jsonassert-library
REST Assured Tutorial 72 – How To Compare Part of JSON Objects and Arrays using JSONassert library
May 14, 2021 - We need to compare that the “address” object in the first JSON Object has the same values for keys as “communicationAddress” in the second JSON Object.
🌐
Google Groups
groups.google.com › g › rest-assured › c › 0NoxuFRhZtE
Re: [rest-assured] Comparing JSon file to part of a response
So is your question is essentially how to compare two JSON documents with each other? This is currently not supported by REST Assured or JsonPath.
🌐
Quora
quora.com › What-is-the-best-way-to-do-API-response-comparison-I-have-been-comparing-the-JSON-response-against-a-stored-JSON-response-using-REST-Assured-framework-Is-there-a-better-way
What is the best way to do API response comparison? I have been comparing the JSON response against a stored JSON response using REST Assured framework. Is there a better way? - Quora
Answer (1 of 2): As long as you are doing data driven testing, atleast your approach is effective. If not, then make your tests data driven. Also, there is a concept called as JsonSchema via which you can test the schema of the response extensively. Kindly refer to the following video for more d...
🌐
Blogger
restservicestesting.blogspot.com › 2021 › 07 › comparing-json-responses-using-json-assert.html
Comparing JSON responses using JsonAssert Library - Lenient Mode
July 23, 2021 - In this post, we would learn about using RequestSpecBuilder in Rest Assured. You can use the builder to construct a request specification. RequestSpecBuilder is normally used when we have common parameters, Base URI, Base Path between different tests. Let's look at an example without RequestSpecBuilder. Here we are making use of Google Search API that we studied in Testing GET Requests and their Responses using Rest Assured .
Find elsewhere
🌐
GitHub
github.com › rest-assured › rest-assured › issues › 595
Add support to compare response body to a template · Issue #595 · rest-assured/rest-assured
September 30, 2015 - I want to have a JSON file with a template of the expected response, load the file contents to a string and then in Rest assured assert that it matches the response body. This will let me verify the response body elegantly at once as a w...
Author   ivos
🌐
Makeseleniumeasy
makeseleniumeasy.com › 2021 › 03 › 08 › rest-assured-tutorial-70-compare-json-objects-using-jsonassert-library
REST Assured Tutorial 70 – Compare JSON Objects using JSONassert Library
March 8, 2021 - For example – If we are going to get the same JSON response for an API every time or some parts of the response are always constant or similar or we just want to check the presence of some fields in another JSON then instead of writing some logic to assert them, we can directly compare with an existing JSON response. We have already compared two JSONs using the Jackson library here.
🌐
Makeseleniumeasy
makeseleniumeasy.com › 2021 › 02 › 19 › rest-assured-tutorial-68-compare-two-json-using-jackson-java-library
REST Assured Tutorial 68 – Compare Two JSON using Jackson – Java Library
February 19, 2021 - We need to convert the given JSON to JsonNode ( or ObjectNode or ArrayNode) first and then we can call the equals method on it.
🌐
Pavantestingtools
pavantestingtools.com › 2024 › 11 › how-to-compare-json-file-with-json.html
SDET-QA Blog: How to Compare a JSON File with a JSON Response
REST Assured sends a GET request and retrieves the JSON response body as a string. ... JSONAssert.assertEquals compares the two JSONs.
🌐
CopyProgramming
copyprogramming.com › howto › how-to-compare-2-json-responses
How to Compare 2 JSON Responses: Complete Guide with Latest Tools & Best Practices 2026 - Json responses complete guide with latest tools
November 22, 2025 - JSON comparison is the process of analyzing two JavaScript Object Notation documents side-by-side to identify all differences between them.
🌐
Makeseleniumeasy
makeseleniumeasy.com › 2021 › 05 › 19 › rest-assured-tutorial-73-how-to-ignore-node-s-for-json-comparison-in-jsonassert
REST Assured Tutorial 73 – How to ignore node/s for JSON comparison in JSONassert
May 19, 2021 - There is no direct way to ignore fields or attributes from a JSON document from comparison. We need to use CustomComparator and explicitly we need to make an assertion pass.