MarshallerMethods
The MarshallerMethods
class contains one-liners for reading and writing
objects to and from XML or JSON.
For Groovy
The methods in this class are intended for use in Groovy, but you may still use them in Gloop using a Groovy
script step and set expressions. A better class to use in Gloop is
JsonMethods
.
GloopMethods
Alternatively, you can use one-liners from GloopMethods
,
JsonMethods
, and
XmlMethods
to help you create Gloop objects from XML or JSON and
vice versa.
Below shows a couple of examples using this class's methods:
1 2 3 4 5 6 7 8 9 10 11 | // Create object def bambi = new Deer( "Bambi", "Mule deer" ) // Create JSON string from object def bambiJsonString = bambi.asJSON() // Create XML string from object def bambiXmString = bambi.asXML() // Re-create the Deer object from the JSON string above def parsedBambi = bambiJsonString.fromJSON(Deer.class) |