Extract data elements from CURL result

I am trying to consume a REST API from within Asterisk 16 dial plan. The CURL call works fine and I get back a JSON array of the data. However, I am trying to extract the value from specific element in the array (_Client) field value and another value , I cannot get it to work. Below is the code I am using and a sample of the CURL_RESULT:

Code:

exten => verify_member_id,1,Set(CURLOPT(ssl_verifypeer)=0)
exten => verify_member_id,n,Set(CURL_RESULT=${CURL(https://127.0.0.1/ivr/api_checkmemberid.php?MEMBERID=${KEY_INPUT_MEMBER_ID})})
exten => verify_member_id,n,Set(curl_status=${SHELL(echo '${CURL_RESULT}' | jq '_Client[0]')})
exten => verify_member_id,n,Verbose(${curl_status})

CURL_RESULT  - Partial
Executing [XXXXXXXXX@XXXXXXX] Set("SIP/IPVP-IN-0000001d", "CURL_RESULT=Array{"_ActiveDisposition":"0","_PaymentMethod":"STATEMENTS","_Unit":"","_Week":"","_Client":"CRCLUB","_DispositionCode":"S","_DispositionCodeDescription":"ServicingTransferred","_PaymentFreq":"A","_LastApplyCodeDesc":"N\/A","_Description":"BILL CHARGES","_PaymentFreqDesc":"ANNUAL".......................}

Anyone have any ideas of what I am doing wrong.

Thank You

I suspect issues with echoing and piping data will pop up at some point. You may want to consider writing an AGI if you do a bunch of extractions.

Using the snippet you provided, I extracted the client in a shell using:

        echo '{"_ActiveDisposition":"0"
                , "_PaymentMethod":"STATEMENTS"
                , "_Unit":""
                , "_Week":""
                ,"_Client":"CRCLUB"
                ,"_DispositionCode":"S"
                ,"_DispositionCodeDescription":"ServicingTransferred"
                ,"_PaymentFreq":"A"
                ,"_LastApplyCodeDesc":"N\/A"
                ,"_Description":"BILL CHARGES"
                ,"_PaymentFreqDesc":"ANNUAL"}'\
                | jq '._Client'

When dealing with data extraction from a json response * php json_encode* () function is one of the best tool, you set the values in an array and then you set the array value to a channel variable assuming you don’t one to use a class like phpagi you can do all this with pure php and Asterisk shell function, python is good option too

Json, redis, native sql … all still missing in Asterisk traditional dialplan, it is really a huge problem that suddenly disappears when you move to pbx_lua, aad as a bonus you get all the features of a programming language and with it your sanity.