<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p.ecxmsonormal, li.ecxmsonormal, div.ecxmsonormal
{mso-style-name:ecxmsonormal;
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p.xecxmsonormal, li.xecxmsonormal, div.xecxmsonormal
{mso-style-name:x_ecxmsonormal;
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hamid,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If would be helpful if you included the part of your script where you copy the REST response into the JSON variable.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There has already been a response to this suggesting that the issue is likely in how you are setting the $json(response) variable. If you want the variable to parse string input into JSON, you must use assignment with := not =. [1]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1] <a href="https://opensips.org/html/docs/modules/2.4.x/json.html#pv_json">
https://opensips.org/html/docs/modules/2.4.x/json.html#pv_json</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="color:black">Ben Newlin </span><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Users <users-bounces@lists.opensips.org> on behalf of Hamid Hashmi <hamid2kviii@hotmail.com><br>
<b>Reply-To: </b>OpenSIPS users mailling list <users@lists.opensips.org><br>
<b>Date: </b>Monday, August 5, 2019 at 2:51 AM<br>
<b>To: </b>"users@lists.opensips.org" <users@lists.opensips.org><br>
<b>Subject: </b>Re: [OpenSIPS-Users] Unable to parse JSON<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC">Opensips Users, <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC">Waiting for your comments/help/Suggestion. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC"><o:p> </o:p></span></p>
</div>
<div id="Signature">
<p class="ecxmsonormal">Regards<o:p></o:p></p>
<p class="ecxmsonormal"><b><span style="font-size:8.0pt;font-family:"Verdana",sans-serif;font-variant:small-caps;color:navy">Hamid R. Hashmi</span></b><o:p></o:p></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Hamid Hashmi<br>
<b>Sent:</b> Tuesday, July 30, 2019 12:40 PM<br>
<b>To:</b> users@lists.opensips.org <users@lists.opensips.org><br>
<b>Subject:</b> Unable to parse JSON</span> <o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC">Below is the JSON response received in an async rest post request (mod rest_client). <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC"> </span><span style="font-size:9.0pt;font-family:"Courier New";color:black">xlog("L_INFO","[$fU $tU $ci $rm] PUSH Server responded with $var(rcode):$json(response)");</span><span style="font-size:12.0pt;color:#2672EC"><br>
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:#2672EC">{</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "error": null,</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "payload": {</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "results": [</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> {</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "error": {</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "code": "messaging/registration-token-not-registered",</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "message": "The provided registration token is not registered. A previously valid registration token can be unregistered for a variety of reasons. See the error
documentation for more details. Remove this registration token and stop using it to send messages."</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> }</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> }</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> ],</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "canonicalRegistrationTokenCount": 0,</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "failureCount": 1,</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "successCount": 0,</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> "multicastId": 4814925980047675000</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black"> }</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New";color:black">}</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC">But when I try to print the following line <br>
<br>
</span><span style="font-size:9.0pt;font-family:"Courier New";color:black;background:white">xlog("L_INFO","[$fU $tU $ci $rm] PUSH Server responded with $var(rcode) with Failure Count: $json(response/payload/failureCount)");</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC;background:white"><br>
<br>
</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC;background:white">it gives me a NULL Value. What am I doing wrong?</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC;background:white"><br>
<br>
</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:#570606;background:white">version: opensips 2.4.6 (x86_64/linux)</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">poll method support: poll, epoll, sigio_rt, select.</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">git revision: edef893c5</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">main.c compiled on 11:29:33 Jul 29 2019 with gcc 4.8.5</span><span style="font-size:12.0pt;color:#2672EC;background:white"><br>
<br>
</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC;background:white"><br>
<br>
</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">[root@sip-3 opc]# rpm -qa | grep json</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">json-c-devel-0.11-4.el7_0.x86_64</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">libfastjson-0.99.4-3.el7.x86_64</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">python-jsonpatch-1.2-4.el7.noarch</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">json-c-0.11-4.el7_0.x86_64</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">json-glib-devel-1.4.2-2.el7.x86_64</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">python-jsonpointer-1.9-2.el7.noarch</span><span style="font-size:12.0pt;color:#2672EC;background:white"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Courier New";color:black;background:white">json-glib-1.4.2-2.el7.x86_64</span><span style="font-size:12.0pt;color:#2672EC;background:white"><br>
<br>
</span><span style="font-size:12.0pt;color:#2672EC"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#2672EC"><o:p> </o:p></span></p>
</div>
<div id="x_Signature">
<p class="xecxmsonormal">Regards<o:p></o:p></p>
<p class="xecxmsonormal"><o:p> </o:p></p>
<p class="xecxmsonormal"><a name="x__MailAutoSig"><b><span style="font-size:8.0pt;font-family:"Verdana",sans-serif;font-variant:small-caps;color:navy">Hamid R. Hashmi</span></b></a><o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>