Hi Age,
Forage wrote:
> Hi,
>
> I'm writing a custom converter to change the default JSON output of maps
> from:
>
> [["first", "value1"], ["second", "value2"]]
>
> To:
>
> {"first" : "value1", "second" : "value2"}
>
> Writing the keys is no problem (startNode), but its string values
> (setValue) never get enclosed by quotes, even if it contains characters
> that need to be escaped to prevent breaking the JSON code. Adding them
> manually with something like the following will leave the escape character
> in the result.
>
> writer.setValue("\""+ var1 + "\"");
>
> I'm using the JsonHierarchicalStreamDriver driver.
>
> How do I overcome this problem?
For JSON the model should internally know what kind of data you're writing.
Therefore you have to tell it with a special call:
((ExtendedHierarchicalStreamWriter)writer).startNode("first", String.class);
writer.writeValue(var1);
Hope this helps,
Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email