Nexial Automation

Test Automation Platform for everyone!

X

json » beautify(json,var)

Description

This command parse json into a beautified version of the same, and stored the formatted content as var. Logically and structurally speaking the content of var should be the same as that of json.

For example, suppose the following JSON document Glossary.json. (excerpt from https://json.org/example.html):

{"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}}

This command will beautify/reformat the JSON content as follows:

{
  "glossary": {
    "title": "example glossary",
    "GlossDiv": {
      "title": "S",
      "GlossList": {
        "GlossEntry": {
          "ID": "SGML",
          "SortAs": "SGML",
          "GlossTerm": "Standard Generalized Markup Language",
          "Acronym": "SGML",
          "Abbrev": "ISO 8879:1986",
          "GlossDef": {
            "para": "A meta-markup language, used to create markup languages such as DocBook.",
            "GlossSeeAlso": [
              "GML",
              "XML"
            ]
          },
          "GlossSee": "markup"
        }
      }
    }
  }
}

Parameters

  • json - the JSON document or file
  • var - the variable name to store the beautified content.

Example

Script:
script

See Also