Hi Thomas,
I don't have control over the string value that gets passed in to me. If I
don't get \" in return, the JSON will be invalid. I'm having similar
problem to this
thread. http://stackoverflow.com/questions/13420115/padding-quotes-in-jsonobject
Thank you
On Monday, March 25, 2013 3:57:19 AM UTC-7, Thomas Broyer wrote:
>
>
>
> On Monday, March 25, 2013 11:23:51 AM UTC+1, rkulisas wrote:
>>
>> //josn is {"name":"item_name","index":0,*"text":"Kindle Fire HD 8.9\"..."
>> *}
>>
>> JSONValue value = JSONParser.parseStrict(json);
>>
>> JSONObject obj;
>>
>> JSONString name, text;
>>
>> JSONNumber nxd;
>>
>> if ((obj = value.isObject()) == null ) return null;
>>
>> if ((value = obj.get("name")) != null)
>>
>> if ((name = value.isString()) != null)
>>
>> field.setName(name.stringValue());
>>
>> if ((value = obj.get("text")) != null)
>>
>> if ((text = value.isString()) != null){
>>
>> System.out.println("VALUE:" + value.toString()); //VALUE:"Kindle Fire
>> HD 8.9\" ..."
>>
>> System.out.println("TEXT:" + text.stringValue()); //TEXT:Kindle Fire HD
>> 8.9" ...
>>
>> field.setText(text.stringValue());
>>
>> }
>> Am I supposed to use JSONValue.toString() to get my string value
>> instead? Why JSONString.stringValue() doesn't parse properly?
>>
>
> The question is more: why do you want the \ to be there?
> It's in your JSON because JSON uses " to markup string literals and thus
> has to escape " that appears within the string value, just like you do in
> Java or JavaScript or so many other languages (C, etc.)
>
> stringValue() *does* return the correct value, it's just that you're
> expecting something else.
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.