资 源 简 介
Jsonizer is a light-weight JSON serializer.
Concept
Template engine like XSLT.
Type-safe mapping.
No reflection.
Getting Started
Download jsonizer-0.9.jar and place it into /WEB-INF/lib.
JSON serialization needs three steps:
Instantiate a Jsonizer object.
Define templates.
Serialize an object to JSON.
```
public class ExampleServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) {
Jsonizer jsonizer = new Jsonizer();
// define a template for class Hoge here
jsonizer.type(Hoge.class).with(new PropertyGetter() {
public void get(Hoge m) {
// mappings between the object and JSON property
property(Datastore.keyToString(e.getKey())).as("key");
property(e.getUrl()).as("url");
property(e.getDate().getTime()).as("date");
}
});
// object to s