[OpenSIPS-Devel] [opensips] JSON Parsing Integers (#494)
Dan Christian Bogos
notifications at github.com
Sun May 3 10:31:38 CEST 2015
Hey Guys,
My scenario: using jsonrpc over http to get information from a remote server inside OpenSIPS.
Request and reply will look like this:
```
T 2015/05/03 10:23:46.296052 127.0.0.1:60767 -> 127.0.0.1:2080 [AP]
POST /jsonrpc HTTP/1.1.
Host: 127.0.0.1:2080.
Accept: */*.
Content-Type: application/json.
Content-Length: 112.
.
{ "id": "1", "method": "ApierV1.GetMaxSessionTime", "params": [ { "Account": "1001", "Destination": "1002" } ] }
May 3 10:23:46 OsipsDev1 /usr/sbin/opensips[2910]: { "id": "1", "method": "ApierV1.GetMaxSessionTime", "params": [ { "Account": "1001", "Destination": "1002" } ] }
#
T 2015/05/03 10:23:46.296983 127.0.0.1:2080 -> 127.0.0.1:60767 [AP]
HTTP/1.1 200 OK.
Content-Type: application/json.
Date: Sun, 03 May 2015 08:23:46 GMT.
Content-Length: 36.
.
{"id":"1","result":-1,"error":null}
```
When receiving the answer, I will use the following xlog statement in opensips:
```
xlog("In CGR_AUTH_REPLY, reply received: $json(cgr_auth_reply), result: $json(cgr_auth_reply/result)");
```
The log would be:
```
#May 3 10:23:46 OsipsDev1 /usr/sbin/opensips[2910]: In CGR_AUTH_REPLY, reply received: {"id":"1","result":-1,"error":null}#012, result: <null>
```
As you can see the reply is properly logged as a serialized json but when extracting the attribute which is an integer, it shows as null.
Ta,
DanB
---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/494
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20150503/6faf0aea/attachment.htm>
More information about the Devel
mailing list