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

Daniel-Constantin Mierla miconda at gmail.com
Fri Nov 3 18:20:40 CET 2017


Hello,

indeed, the format was wrong, I just pushed a patch for it in master and
branch 5.0:

  -
https://github.com/kamailio/kamailio/commit/0956257ae6fdc0a801ce109017089ac18018e63b

Cheers,
Daniel

On 03.11.17 17:01, Marrold wrote:
> 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
>
>
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training, Nov 13-15, 2017, in Berlin - www.asipto.com
Kamailio World Conference - www.kamailioworld.com

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


More information about the sr-users mailing list