Tell me if Asterisk can work with json format!

  • It depends on what you want to get. - StuxForce
  • I need to parse a line like ["item1", "item2", "item3", "item4"] - quaresma89
  • one
    Then you can use a third-party script and call it through AGI. Upon completion, transfer the result to asterisk. wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_AGI - StuxForce

1 answer 1

It is possible through a third-party script, and it is possible through JSONELEMENT https://github.com/drivefast/asterisk-res_json

exten => _X.,1,Set(CURL_RESULT=${CURL(http://domain.com/test.json)}) same => n,Set(result=${JSONELEMENT(CURL_RESULT,result/subfield)}) same => n,GotoIf($["${result}" = "1"]?result1:result2) same => n(result1),Verbose(Result 1) 
  • I made it easier, instead of Jason I returned the string separated by commas, and already in the asterisk using the SHIFT function I sparsil - quaresma89