XML/JavaScript Converter Builder
This builder adds code to the Web application to convert XML data into JSON (JavaScript Object Notation) format. It's main input is an indirect reference called
Data Reference
that indicates the source of the XML data. The builder adds a method with the same name as the builder call with "ConvertToJSON" appended, which converts the XML data to JSON.
Specifying inputs
This builder takes the inputs described in the table below. For help on inputs common to many or all builders such as those in the Properties and HTML Attributes input groups, see Using the Builder Call Editor.
Input name Description Name Enter a name for this builder call. The designer tool displays this name in the builder call list. This name is also used as the base value for the method that converts XML to JSON: the string ConvertToJSON
is appended to the builder call name.Data Reference Reference to a variable or method call that returns the XML data to be converted. Callback Optional name of a JavaScript function to which the data is passed. This function must be defined elsewhere. If specified, the resulting JavaScript starts with the callback name followed by the JSON code in parentheses. Conversion Options Mark Attributes If checked, XML attributes are prefixed with an @
symbol in the generated JSON to distinguish them from elements.Text Node Property Indicate the property name to be represented in the JSON output for text in elements that have other children. For example, using the default value of "#text" for this input, <a>b<c>d</c></a> becomes
{ "a" : { "#text": "b", "c" : "d" } } Alternatively, use "$" to produce JSON as specified by the "BadgerFish" convention.
Output Settings Write Directly If checked, the JavaScript is sent directly to the servlet output stream. Otherwise, the script code is returned to the caller for further processing. We can select this to optimize performance for cases where the generated JSON code should be used without further modification. Content Type Indicate the value that should be used as the Content-Type header. This input is visible only when Write Directly is checked. The default value is "application/javascript".
Related topics