You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Brendan cheng <cc...@hotmail.com> on 2011/09/19 14:22:46 UTC

JSON usage

Hi,
I was trying to use your api for JSON parse.How to construct a JSON using your API?you provide a JSON.parse which generate a sequence of String only.
BrendanĀ  		 	   		  

Re: JSON usage

Posted by Greg Brown <gk...@verizon.net>.
Sorry, I meant JSONSerializer, not JSON. JSON#parse() is used to parse a JSON path (such as "foo.bar[100]") into a sequence of string keys. JSONSerializer#parse() will read JSON data into a Java object representation.

On Sep 19, 2011, at 11:03 AM, Brendan cheng wrote:

> 
> Hi Greg,
> When I run this:
> JSON.parse("{a: 100, b: 200}");
> I got illegal identifier character.
> ----------------------------------------
>> Subject: Re: JSON usage
>> From: gk_brown@verizon.net
>> Date: Mon, 19 Sep 2011 08:36:22 -0400
>> To: user@pivot.apache.org
>> 
>> JSON.parse() returns an object appropriate for the input. So, if you called:
>> 
>> JSON.parse("['a', 'b', 'c']");
>> 
>> you'd get a String sequence. However, if you called:
>> 
>> JSON.parse("[0, 1, 2]");
>> 
>> you'd get an Integer sequence. If you called:
>> 
>> JSON.parse("{a: 100, b: 200}");
>> 
>> you'd get a Map<String, Object> containing keys "a" and "b". If you called:
>> 
>> JSON.parse("'Hello'");
>> 
>> you'd get a String, and if you called:
>> 
>> JSON.parse("100");
>> 
>> you'd get an Integer.
>> 
>> Basically, you get back the Java equivalent of the JSON value you pass in.
>> 
>> On Sep 19, 2011, at 8:22 AM, Brendan cheng wrote:
>> 
>>> 
>>> Hi,
>>> I was trying to use your api for JSON parse.How to construct a JSON using your API?you provide a JSON.parse which generate a sequence of String only.
>>> Brendan
>> 
> 		 	   		  


RE: JSON usage

Posted by Brendan cheng <cc...@hotmail.com>.
Hi Greg,
When I run this:
JSON.parse("{a: 100, b: 200}");
I got illegal identifier character.
----------------------------------------
> Subject: Re: JSON usage
> From: gk_brown@verizon.net
> Date: Mon, 19 Sep 2011 08:36:22 -0400
> To: user@pivot.apache.org
>
> JSON.parse() returns an object appropriate for the input. So, if you called:
>
> JSON.parse("['a', 'b', 'c']");
>
> you'd get a String sequence. However, if you called:
>
> JSON.parse("[0, 1, 2]");
>
> you'd get an Integer sequence. If you called:
>
> JSON.parse("{a: 100, b: 200}");
>
> you'd get a Map<String, Object> containing keys "a" and "b". If you called:
>
> JSON.parse("'Hello'");
>
> you'd get a String, and if you called:
>
> JSON.parse("100");
>
> you'd get an Integer.
>
> Basically, you get back the Java equivalent of the JSON value you pass in.
>
> On Sep 19, 2011, at 8:22 AM, Brendan cheng wrote:
>
> >
> > Hi,
> > I was trying to use your api for JSON parse.How to construct a JSON using your API?you provide a JSON.parse which generate a sequence of String only.
> > Brendan
>
 		 	   		  

Re: JSON usage

Posted by Greg Brown <gk...@verizon.net>.
JSON.parse() returns an object appropriate for the input. So, if you called:

  JSON.parse("['a', 'b', 'c']");

you'd get a String sequence. However, if you called:

  JSON.parse("[0, 1, 2]");

you'd get an Integer sequence. If you called:

  JSON.parse("{a: 100, b: 200}");

you'd get a Map<String, Object> containing keys "a" and "b". If you called:

  JSON.parse("'Hello'");

you'd get a String, and if you called:

  JSON.parse("100");

you'd get an Integer.

Basically, you get back the Java equivalent of the JSON value you pass in.

On Sep 19, 2011, at 8:22 AM, Brendan cheng wrote:

> 
> Hi,
> I was trying to use your api for JSON parse.How to construct a JSON using your API?you provide a JSON.parse which generate a sequence of String only.
> Brendan