0

I have a API response below. I want to fetch a value from the response which inside a JSON array.

{
  "cipherTexts": [
    {
      "id": "string1",
      "isSensitive": false,
      "cipherText": "gO/GSiH0Co1Ibw=="
    }
  ]
}

I am using JsonPath class to fetch

String resp = response.asString();
JsonPath js = new JsonPath(resp);
js.get("cipherText").toString();

Anyone please help me here how to get the value for "id" or "cipherText" ???

lucas-nguyen-17
  • 5,516
  • 2
  • 9
  • 20
Adil Raza
  • 65
  • 6

1 Answers1

0

The correct path would be:

js.get("cipherTexts[0].id")
//or
js.get("cipherTexts[0].cipherText")
lucas-nguyen-17
  • 5,516
  • 2
  • 9
  • 20