public class ConvertorOperator extends Object
convert("{ \"age\": 22}").into([result]);
produces
result = {"age" : 22}
It works similarly with XML inputs. Say you have the following XML document in an input String
<xml version="1.0" encoding="UTF-8">
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty of real maple syrup
</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
Light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>
Belgian waffles covered with assorted fresh berries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>
Thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
</food>
</breakfast_menu>
Running the following code :
convert([message]).into([result]);
produces the following tuple:
{
"result": {
"breakfast_menu": {
"food": [
{
"calories": 650,
"description": "Two of our famous Belgian Waffles with plenty of real maple syrup",
"name": "Belgian Waffles",
"price": "$5.95"
},
{
"calories": 900,
"description": "Light Belgian waffles covered with strawberries and whipped cream",
"name": "Strawberry Belgian Waffles",
"price": "$7.95"
},
{
"calories": 900,
"description": "Belgian waffles covered with assorted fresh berries and whipped cream",
"name": "Berry-Berry Belgian Waffles",
"price": "$8.95"
},
{
"calories": 600,
"description": "Thick slices made from our homemade sourdough bread",
"name": "French Toast",
"price": "$4.50"
},
{
"calories": 950,
"description": "Two eggs, bacon or sausage, toast, and our ever-popular hash browns",
"name": "Homestyle Breakfast",
"price": "$6.95"
}
]
}
Constructor and Description |
---|
ConvertorOperator(String input)
Create a new converter operator for a given input String
|
Modifier and Type | Method and Description |
---|---|
boolean |
into(Tuple output)
Parse the input string and returns true if it was successfully converted into the output punch tuple.
|
public ConvertorOperator(String input)
input
- the input stringpublic boolean into(Tuple output)
output
- the output punch tupleCopyright © 2022. All rights reserved.