My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FAQ  
Frequently Asked Questions
Featured
Updated Sep 22, 2011 by harald.pehl

References are not mapped

To map references it is important that all readers are initialized before the first POJO is read. Initialized means the call of GWT.create() has to happen. As long as you declare your reader / writer instances as static members, Piriti will take care of this. Once you have your reader / writer instances outside of your POJO, you have to take care of the initialization by yourself. See reference requirements for more details.

Different paths for JSON and XML

If you want to have both JSON and XML readers you can share most of the settings, but will most likely have different paths. In this case you can use external mappings to overwrite the default path names. See external mappings for more details.

Select distinct JSON / XML data for mapping

Suppose you got the following JSON data and you just want to map the "result" node to a "User" POJO.

{
  "version":"1.0",
  "retcode": 0,
  "result": {
    "name" : "Max",
    "age" : 20
  }
}

This can be done using the following approach:

JSONObject json = JSONParser.parseStrict(response.getText()).isObject();
JSONObject result = JsonPath.select(json, "@.result").isObject();
User user = UserReader.INSTANCE.read(result);

Sign in to add a comment
Powered by Google Project Hosting