0

How to get jsonObjects from this below rest api response, using restAassured and java.

My rest api is returning response as below.

[
    {
        "id": {
            "value": "1"
        },
        "fieldName": "input",
        "jobId": "234"
    },
    {
        "id": {
            "value": "2"
        },
        "fieldName": "output",
        "jobId": "223"
    }
]

I have tried using rest assured response parsing methods like jsonPath(), getJsonObject() etc., nothing works. Can you please help.

Umair Mubeen
  • 823
  • 4
  • 22
Venu
  • 3
  • 2

1 Answers1

0
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode arrayNode = objectMapper.readValue(<OUTPUT_STRING>,ArrayNode.class)
Santosh b
  • 729
  • 1
  • 8
  • 19
  • Hi Santhosh, I am not clear on how to use your solution on restassured API response. Could you please elaborate. – Venu Jul 21 '20 at 08:43
  • 1
    Thanks Santosh, it worked for me. I was using restassured objectmapper initially later tried jackson core one, it worked. – Venu Jul 21 '20 at 08:59