This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Functions - xmlutils

fromJSON

Converts a JSON object to an XML representation.

fromTable

Converts a table to its XML representation.

fromJSON

(json? jsonValue, JsonOptions options)

returns xml | error

Converts a JSON object to an XML representation.

 json data = {
     name: "John",
     age: 30
 };
 xml|error xmlValue = xmlutils:fromJSON(data);

Parameters

  • jsonValue json?
  • The JSON source

  • options JsonOptions (default {})
  • The xmlutils:JsonOptions record for JSON to XML conversion properties

  • Return Type

    (xml | error)
  • XML representation of the given JSON if the JSON is successfully converted or else an error

fromTable

(table tableValue)

returns xml

Converts a table to its XML representation.

 table<Person> personTable = table{
     { key id, age, salary, name, married },
     [ { 1, 30,  300.5, "Mary", true },
         { 2, 20,  300.5, "John", true }
     ]
 };
 xml xmlValue = xmlutils:fromTable(personTable).toString();

Parameters

  • tableValue table
  • The table value to be converted to an XML

  • Return Type

    (xml)
  • The XML representation of the provided table