Support Questions

Find answers, ask questions, and share your expertise

How can I extract this key value "9876" from the given json using Jolt spec?

avatar
Explorer
This is the json data I am getting as an response from an API and I need to extract this "9876 or 9875" from this, How can I extract this value from this type of data.

 

 {
  "status": "pass",
  "values": {
    "WorkFlow": 0,
    "Reasons": {
      "resID": "",
      "options": {
        "9876": [
          "t1",
          "t2"
        ],
       "9875":[],
       "9874":[]
       }
     }
   }
}

 

 

2 REPLIES 2

avatar
Super Guru

Hi,

Can you explain on what basis are you trying to extract "options":  9876 & 9875 only  and not 9874? Is it based on the index as in the first option and the second option only and ignore anything after?

 

avatar
Explorer

Actually I want to extract all three or there can be more such like n options, So I need to extract all these n options, I explain it a bit wrong Sorry for that. All of them will have some values and I need to extract that one by one.

 

I cant edit the question now, its not allowing.

{
  "status": "pass",
  "values": {
    "WorkFlow": 0,
    "Reasons": {
      "resID": "",
      "options": {
        "9876": [
          "t1",
          "t2"
        ],
       "9875":[
"t1", "c2"
], "9874":[
"x1", "a2"
] } } } }

 

There can N number of options, not only these 3 (9876,9875,9874) and I have to extract all of those options because I have to run API using on all these values one by one thats why I have to extract them one by one and store them in some variable.

 

Flow is like :  First option(9876) will be extracted in some variable -> we will check if it is empty or not -> if not empty -> it will call an API using this(9876) option -> same will happen for all the option one by one.

 

But I am unable to fetch these options one by one.