Piriti
JSON and XML Mapper for GWT
Install / Use
/learn @hpehl/PiritiREADME
What the heck is piriti
Piriti (Maori for "bridge") is a JSON and XML mapper for GWT based on reasonable defaults, a handful of annotations and deferred binding. The following code snippets show the basic ideas behind Piriti.
XML Mapping
In case you have the following XML document
<vub readonly="true">
<name>Foo</name>
<createdAt>08.01.2010</createdAt>
<count>20</count>
</vub>
and the model class
public class VirtualUserBundle
{
interface VubReader extends XmlReader<VirtualUserBundle> {}
public static final VubReader XML = GWT.create(VubReader.class);
int count;
String name;
@Path("@readonly") boolean readonly;
@Format("dd.MM.yyyy") Date createdAt;
}
you can turn the XML into an instance of VirtualUserBundle by calling
Document document = new XmlParser().parse(xmlAsString);
VirtualUserBundle vub = VirtualUserBundle.XML.read(document);
JSON Mapping
JSON mapping works very similar. In case you have the following JSON data
{ "readonly": true, "name": "Foo", "createdAt": "08.01.2010", "count": 20 }
and the model class
public class VirtualUserBundle
{
interface VubReader extends JsonReader<VirtualUserBundle> {}
public static final VubReader JSON = GWT.create(VubReader.class);
int count;
String name;
boolean readonly;
@Format("dd.MM.yyyy") Date createdAt;
}
you can map the JSON data to an instance of VirtualUserBundle by calling
String jsonString = ... // the above JSON data
VirtualUserBundle vub = VirtualUserBundle.JSON.read(jsonString);
Related Skills
node-connect
354.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
