<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix"><tt>Hi, Brett!</tt><tt><br>
</tt><tt><br>
</tt><tt>The only problem I can see with your construction is that
you do not properly initialize the </tt><tt><tt>JSON</tt>
object: </tt><tt>$json(foo) = "{}". When the "=" operator is
used, the "{}" is interpreted as a simple string, not as a </tt><tt><tt>JSON</tt>
format. You should have used the ":=" which parses "{}" as a
JSON format and constructs a proper </tt><tt><tt>JSON</tt>
structure, that is populated afterwards with the desired value.</tt><tt><br>
</tt><tt>Anyway, I am not sure why you get that bogus "value".
When I replicated your code, the JSON module returns an error
when the $json(foo/bar) value is retrieved.</tt><tt><br>
</tt><tt><br>
</tt><tt>Best regards,</tt><br>
<pre class="moz-signature" cols="72">Razvan Crainea
OpenSIPS Core Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a>
</pre>
On 01/01/2013 08:21 PM, Brett Nemeroff wrote:<br>
</div>
<blockquote
cite="mid:CAPwC5wy5A1KZRTOge0Cp1YR3wCyh1ZMiAR-8Ru5SE9mBS+WriA@mail.gmail.com"
type="cite">Hey All, I'm using 1.8.2-notls (9330) and I'm having
some odd issues with the JSON module.
<div><br>
</div>
<div>If I create an object with json like this:</div>
<div><br>
</div>
<div>$avp(baz) = "opensips";</div>
<div>$json(foo) = "{}"</div>
<div>$json(foo/bar) = $avp(baz);</div>
<div><br>
</div>
<div>And then I:</div>
<div>xlog("L_INFO","Value of JSON foo/bar is: $json(foo/bar)");</div>
<div><br>
</div>
<div>
I'll get something like this:</div>
<div><br>
</div>
<div>"Value of JSON foo/bar is: opensips>?Q#177"</div>
<div><br>
</div>
<div>The ">?Q#177" bit changes from run to run. Looks like
memory not initialized properly?</div>
<div><br>
</div>
<div>Now.. if I display the entire contents of foo:</div>
<div><br>
</div>
<div>xlog("L_INFO","JSON Object Debug: $json(foo)");</div>
<div><br>
</div>
<div>It looks exactly how I'd expect it:</div>
<div>{ "bar": "opensips"}</div>
<div><br>
</div>
<div><br>
</div>
<div>Additionally, if I push the object into something else, like
memcache and then retrieve it back with the := operator, it then
works perfectly (ie: json object behaves differently if it was
created with a := versus explicitly identifying the paths). </div>
<div><br>
</div>
<div>Anyone else run into this? </div>
<div><br>
</div>
<div>Additionally, I can't seem to push VALUES that have special
characters in it. I tried to store a typical "datetime" object
(2012-12-12 12:12:12 for example) and all I get back is "2012".
If I uriencode it, it works (my workaround for now).</div>
<div><br>
</div>
<div>Thoughts?</div>
<div><br>
</div>
<div>Thanks!</div>
<div>-Brett</div>
<div><br>
</div>
<div><br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>