On Feb 11, 2010, at 12:28 AM, Will Scheidegger wrote:
>
> Dear Magnolians
>
> I'm currently working on a custom control which posts a JSON string to the
> dialog save handler - a list of objects, e.g.
>
> [{"description": "Dinner", "price": "25.85", "date": "2010-02-10"},
> {"description": "Train ticket", "price": "48.2", "date": "2010-02-10"},
> {"description": "Solution to JSON problem", "price": "priceless"}]
>
> The custom control works fine and JavaScript has now problems turning this
> String into an array of objects. Unfortunately I have not found an easy way
> to do the same with
> the json-lib which comes with Magnolia.
http://json-lib.sourceforge.net/
> All I would like to do is to simply convert the string above into a
> Collection object containing three Map objects. Maybe I'm missing something
> obvious (easily possible since it's been a long day) or this json-lib does
> not make thinks as easy as they could be. So any pointers are warmly
> appreciated!
Wild guess, something along the lines of
final JSONObject json = new JSONObject(jsonString);
return (Collection) JSONObject.toBean(json, Collection.class);
.. you could also try the static fromObject() methods with your expected
result, to see the kind of string this will give you.
Cheers,
-g
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------