Hi all,

I'm trying to parse the result of a json rpc call to get the register statistics.


# Get registrar stats
jsonrpc_exec('{"jsonrpc": "2.0", "method": "stats.get_statistics", "params": ["accepted_regs"], "id": 1}');
jansson_get("result[0]", $jsonrpl(body), "$var(registrar_accepted)");
xlog("LOG_LOCAL3","L_WARN","$jsonrpl(body)\n");

The $jsonrpl(body) var contains: {"jsonrpc":"2.0","result":["registrar:accepted_regs = 2"],"id":1}


With this code the result stored in $var(registrar_accepted) is : "AcceptedRegistrations":"registrar:accepted_regs = 1"

I'm trying to get only the value. I have tried:

jansson_get("result[0].registrar:accepted_regs", $jsonrpl(body), "$var(registrar_accepted)"); jansson_get("result[0].['registrar:accepted_regs']", $jsonrpl(body), "$var(registrar_accepted)"); jansson_get("result[0]['registrar:accepted_regs']", $jsonrpl(body), "$var(registrar_accepted)");

But this does not work. Do i need to escape the colon in the object name "registrar:accepted_regs" ?

Thanks,

Jan

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to