JSON Bug, empty strings

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JSON Bug, empty strings

Brett Nemeroff
Hey all,
I think I see a bug in the JSON module; but it might just be a "feature" of JSON.

Seems that when I assign an empty string to a JSON element, it's storing it as NULL. So for example:

$json(object/element) = '';

If I print that, I get <null> in an xlog.

Is this expected? I'd really like to be able to store empty strings.

Thanks!
-Brett


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: JSON Bug, empty strings

shaheryarkh
I think libjson_c treats empty string as null. Let me run some tests to confirm it.

Thank you.


On Sun, Feb 10, 2013 at 6:39 PM, Brett Nemeroff <[hidden email]> wrote:
Hey all,
I think I see a bug in the JSON module; but it might just be a "feature" of JSON.

Seems that when I assign an empty string to a JSON element, it's storing it as NULL. So for example:

$json(object/element) = '';

If I print that, I get <null> in an xlog.

Is this expected? I'd really like to be able to store empty strings.

Thanks!
-Brett


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: JSON Bug, empty strings

shaheryarkh
Nope, i was wrong. It works fine.

        $json(object) := "{'id':'1234567890','name':NULL}";
        $json(object/element) = '';

        xlog("L_WARN", "id: $json(object/id), name: $json(object/name), element: $json(object/element)");

Results as,

Feb 10 19:39:47 ubuntu-1204 osip-service[13705]: id: 1234567890, name: <null>, element:

Also, here is null value test,



Thank you.


On Sun, Feb 10, 2013 at 8:05 PM, Muhammad Shahzad <[hidden email]> wrote:
I think libjson_c treats empty string as null. Let me run some tests to confirm it.

Thank you.


On Sun, Feb 10, 2013 at 6:39 PM, Brett Nemeroff <[hidden email]> wrote:
Hey all,
I think I see a bug in the JSON module; but it might just be a "feature" of JSON.

Seems that when I assign an empty string to a JSON element, it's storing it as NULL. So for example:

$json(object/element) = '';

If I print that, I get <null> in an xlog.

Is this expected? I'd really like to be able to store empty strings.

Thanks!
-Brett


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]



--
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: [hidden email]
Email: [hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: JSON Bug, empty strings

Bogdan-Andrei Iancu-2
In reply to this post by Brett Nemeroff
Hi Brett,

Empty string is not a valid json string....maybe "{}".
Check the grammar on http://www.json.org/ and a validator on  http://jsonlint.com/

Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 02/10/2013 07:39 PM, Brett Nemeroff wrote:
Hey all,
I think I see a bug in the JSON module; but it might just be a "feature" of JSON.

Seems that when I assign an empty string to a JSON element, it's storing it as NULL. So for example:

$json(object/element) = '';

If I print that, I get <null> in an xlog.

Is this expected? I'd really like to be able to store empty strings.

Thanks!
-Brett

_______________________________________________ Users mailing list [hidden email] http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users