Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

REST. Checking the type of incoming field

how can I check the field type of the incoming response to the REST request.

For example, I receive an answer with the
"pay" field:"1000"
I want to check that the incoming field, its value is of type int
What verification methods are there?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use Rest Assured

Say you have this endpoint: https://mocki.io/v1/0f2701f8-46ab-48b5-9584-7e58da29498d

that returns:

{
  "pay": 1000
}

Then your code could be:

public static void main(String[] args) throws URISyntaxException {
    System.out.println(RestAssured
            .get(new URI("https://mocki.io/v1/0f2701f8-46ab-48b5-9584-7e58da29498d"))
            .jsonPath()
            .get("pay") instanceof Integer);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading