thanks in advance
Paul
Le 14 mars 2012 à 13:14, Marius Dumitru Florea a écrit :
On Wed, Mar 14, 2012 at 12:26 PM, Guillaume
Delhumeau
<gdelhumeau(a)xwiki.com> wrote:
Hi.
Can't you add a parser function too ?
A parser function needs to return an object:
* either the JSON object from some JSON library, but that means
binding the Velocity tool to a specific JSON library and I tried to
avoid this for the moment until we reach an agreement regarding the
JSON library to use
* a wrapper for the JSON object from some JSON library to hide the
JSON implementation, but that's a lot of work and I don't have time
for it right now
* a Java object, but for this you need a JSON-Java mapping, which is
specific to the JSON library used and it requires some work to make a
generic binding method
Right now, we have to use groovy for JSON parsing. It would be better to
have it in velocity directly, don't you think ?
Yes, but I don't have time for it right now.
Thanks,
Marius
Thanks,
Guillaume
2012/3/14 Andreas Jonsson <aj(a)member.fsf.org>
+1
2012-03-14 09:08, Marius Dumitru Florea skrev:
> Hi devs,
>
> Following the discussion on
>
http://lists.xwiki.org/pipermail/devs/2012-March/049889.html I'd like
> to add a JSON Velocity tool that has (for now) just one method:
>
> /**
> * Serialize a Java object to the JSON format.
> * <p>
> * Examples:
> * <ul>
> * <li>numbers and boolean values: 23, 13.5, true, false</li>
> * <li>strings: "one\"two'three" (quotes
included)</li>
> * <li>arrays and collections: [1, 2, 3]</li>
> * <li>maps: {"number": 23, "boolean": false,
"string": "value"}</li>
> * <li>beans: {"enabled": true, "name": "XWiki"}
for a bean that has
> #isEnabled() and #getName() getters</li>
> * </ul>
> *
> * @param object the object to be serialized to the JSON format
> * @return the JSON-verified string representation of the given object
> */
> public String serialize(Object object)
>
> This method is able to do what both of the initially proposed methods
> were able and it doesn't expose the JSON library used (so that we can
> change it later if we want). I'll use json-lib for the initial
> implementation and we can move to Jackson or other JSON library later.
>
> WDYT? I'd like to commit this ASAP.
>
> Thanks,
> Marius
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
>
http://lists.xwiki.org/mailman/listinfo/devs
> .
>
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs