This page provides a service allowing online testing of json-transforming. The Json-transforming service basically takes XML definitions of message objects and generates POJOs. Normally definitions are kept in XML files. However, this service allows you to do the definitions interactively and allows you to do definitions and transformations interactively.
In the syntax section below you can read about the syntax used when defining message objects in XML.
The POJO Json Project is a utility for generate POJOs from sparse definitions. Generated message objects will have the ability to serialize themselves to Json and/or Mongo BSON objects, in most efficient way. In addition, basic Json Schema definitions could also be generated for messages objects.
The project is an open source project and it could be found in GITHUB
The Message tag encapsulate the definition for a message object that is provided as a Java class. The message element could have the following attributes
<Message name="TestMessage" rootMessage="true" db="true" dbCollection="Test">
Attribute is used as part of a message definition and defines an attribute for the message. The following attributes can be used in conjuction with a XML Attribute tag;
<Attribute name="intArray" type="int" list="array"/>
The following types can be used when defining a message object attribute.
Attribute Type | Java Type | Json Type | Mongo Type |
---|---|---|---|
boolean | <Optional> Boolean | boolean | Boolean |
byte | <Optional> Byte | Number | Int32 |
short | <Optional> Short | Number | Int32 |
int | <Optional> Integer | Number | Int32 |
long | <Optional> Long | Number | Int64 |
double | <Optional> Double | Number | Double |
char | <Optional> Character | Number | Int32 |
String | <Optional> String | String | String |
byte[] | <Optional> byte[] | String (hex) | String (hex) |
Map | <Optional> Map<String,String> | Object {String,String} * n | Object {String,String} * n |
LocalDateTime | <Optional>LocalDateType | String "yyyy-MM-dd HH:mm:ss.SSS" | String "yyyy-MM-dd HH:mm:ss.SSS" |
LocalDate | <Optional>LocalDate | String "yyyy-MM-dd" | String "yyyy-MM-dd" |
Message objects could besides having navtive attributes also have message Object as attribute. Worth mention is the difference between a rootMessage object and a none rootMessage. The difference is how the message object is Json encoded.
<Message name="FooMessage" rootMessage="true">
<Attribute name="barValue" type="int"/>
</Message>
It is possible to let a message object attribute to be a rootMessage but that will implicate the extra (Json) object level.
It is said that a message object attribute always have a "type" definition, true with one excemption :-) If the attribute is a constant group the attribute does not have a type for the <Attribute> has either "type" or "constantGroup". A constant group definitions translates to a Java Enumeration. An example of a constant group follows below;
<ConstantGroups prefix="Core">
<Group name="CG1">
<Constant id="X1"/>
<Constant id="X2"/>
</Group>
</ConstantGroups>
<Message name="FooMessage" rootMessage="true">
<Attribute name="barValue" constantGroup="CG1"/>
</Message>