Convert
Converts the value to the type chosen in To, such as the text 10 from a form field to the number a step's field takes. A value that can't be read as that type fails the step rather than being guessed at. Text, Number, and True or False convert each item of a list in turn; Parse JSON, Parse XML, and JSON Text work on the value whole.
| To | Input | Output |
|---|---|---|
| Text | 3, true | 3, true as text |
| Number | 42, -1.5 as text | 42, -1.5 |
| True or False | TRUE, 0, 7 | true, false, true |
| Parse JSON | {"id": 7, "tags": ["a", "b"]} | An object with id and tags |
| Parse XML | <order id="7"><total>12.50</total></order> | An object with order holding id and total |
| JSON Text | An object with id and tags | {"id":7,"tags":["a","b"]} |
The Convert reference describes each field, in the same words its Guide icon shows in the tool.
Text
Converts a number to its text, written plainly, such as 3 rather than 3.0, and true or false to the words. An object fails the step; use JSON Text for that.
Number
Converts text that is a number, such as 42 or -1.5, to the number.
True or False
Converts true or false, written in any case, to the value, and a number to false when it is zero and true otherwise. Other text, such as yes, fails the step, as a typed field reads it.
Parse JSON
Converts JSON text to the object, list, or other value it writes. A value that is already an object or a list passes on unchanged.
Parse XML
Converts XML text to an object. A value that is already an object or a list passes on unchanged.
A document reads as an object with one field, named for its root element, so <order id="7"><total>12.50</total></order> reads as order holding id and total, and Extract Path order/total picks out 12.50. Every value is text, since XML doesn't say which values are numbers; follow with Convert to Number where a step needs one.
How XML is read
- An element with neither attributes nor child elements reads as its text, with surrounding whitespace removed, or as empty text when it has none.
- An element with attributes or child elements reads as an object holding both by name, with any text of its own under
#text, so<price currency="USD">12.50</price>reads ascurrencyand#text. - A name used more than once in an element, whether by attributes or child elements, holds a list of their values in document order. A name used once holds the value alone, so a path into an element that can repeat should allow for both.
- Namespace prefixes are removed from names, so
dc:titlereads astitle, and namespace declarations are left out. - Comments and processing instructions are skipped. A document type declaration is skipped too, so an entity it declares can't be used, and nothing outside the text is fetched.
- XML escaped inside another document, such as an event carried in an element's text, reads as that text, so a second Parse XML after an Extract Path reads the inner document in turn.
JSON Text
Converts any value to JSON text, such as an object for a field that takes text.