user2756501
user2756501

Reputation: 1

Using Rest assured to validate saved JSON response

I have a question regarding REST Assured. - https://code.google.com/p/rest-assured/wiki/Usage

I understand that I can use REST assured to make HTTP calls(.get .put etc.) and validate the response using when() etc. I would like to validate JSON responses that I have already saved in the database, instead of Calling the web service realtime and validating it's response.

Can I use REST-assured to Load a JSON response as a String and validate it?

Upvotes: 0

Views: 2157

Answers (1)

Johan
Johan

Reputation: 40618

Yes you can use Rest Assured's JsonPath project independently of Rest Assured (see getting started page). Once you have it in classpath you can do something like this:

JsonPath jsonPath = new JsonPath(<your json as string>);
String title = jsonPath.getString("x.y.title");

Upvotes: 2

Related Questions