Skip to content

Utils

Purpose

Provides utility methods.

Methods

Binding name: p6.utils

Method: String p6.utils.escapeXml(String xmlStr)

Escape the given XML string.


Method: XPath p6.utils.getXPath()

Provide a javax.xml.xpath.XPath using the Saxon factory.


Method: String p6.utils.unescapeXml(String escStr)

Unescape the given escaped XML string.


Method: String p6.utils.pause()

Pauses the execution until Platform 6 is stopped or the user manually stops the script via the UI.


Method: String jsonToString(Map<?, Object> json)

Convert the JSON to a stringify and pretty print version (Converted using JsonOutput toJson and prettyPrint)


Method: Object stringToJson(String json)

Convert the string to a JSON (Converted using JsonSlurper.parseText)

Examples

println p6.utils.espaceXml("<root><node>value</node></root>")

println p6.utils.unescapeXml("&lt;root&gt;&lt;node&gt;value&lt;/node&gt;&lt;/root&gt;")

println p6.utils.pause()

println p6.utils.jsonToString([
  names: ["fee", "foo", "bar"],
  values: [1, 2]
])

println p6.utils.stringToJson("{\"names\": [\"fee\", \"foov, \"bar\"], \"values\": [1, 2]}")