[SR-Users] Invalid JSON when dumping htable with JSONRPC-S

Marrold kamailio at marrold.co.uk
Fri Nov 3 17:01:52 CET 2017


Hi All,

I am currently trying to retrieve the contents of a htable using the
JSONRPC-S module over HTTP, however I have observed if a slot contains
multiple values, the JSON returned has duplicate keys which could be
considered invalid.

Here are the relevant lines from kamailio.cfg -

event_route[xhttp:request] {
    if ($hu =~ "^/carrier") {
        jsonrpc_exec('{"jsonrpc": "2.0", "method": "htable.dump", "params"
: {"htable": "carrier"}, "id": 1}');
        xhttp_reply("200", "OK", "text/html", "$jsonrpl(body)");
    }
}

And the output, showing a slot with two items-


{
"entry": 5,
"size": 2,
"slot": {
"item": {
"name": "carrierA",
"value": "90",
"type": "str"
},
"item": {
"name": "carrierB",
"value": "190",
"type": "str"
}
}
}

And the same from `kamcmd -s unix:/tmp/kamailio_ctl htable.dump carrier` -

{
entry: 5
size: 2
slot: {
item: {
name: carrierA
value: 90
type: str
}
item: {
name: carrierB
value: 190
type: str
}
}
}

Would it be possible to change it to something like the following -

{
    "entry": 5,
    "size": 2,
    "slot": [
        {
            "name": "carrierA",
            "value": "90",
            "type": "str"
        },
        {
            "name": "carrierB",
            "value": "190",
            "type": "str"
        }
    ]
}

Any other suggestions or work arounds would be appreciated,

Thanks
Matthew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20171103/e4930573/attachment.html>


More information about the sr-users mailing list