Email: evarainbow@evarainbow.com

JSON – Cisco Automation and Scripting Tools

JavaScript Object Notation (JSON) is a lightweight text-based open standard designed for human-readable data interchange.

JSON objects contain data in a consistent format that can be passed and programmatically consumed more easily than the data in report formats. A JSON object is an unordered set of name/value pairs, so it tends to be self-explanatory, like XML, but it is less bulky.

Parameters for JSON objects are passed in the following format: ParameterName:parameterValue. A proper JSON object begins with a left brace { and ends with a right brace }. Each name in a pair is followed by a colon (:) and then the corresponding value. The name/value pairs are separated by commas.

Example 16-17 displays a fragment from a JSON document that shows how you might structure some simple data about a network device.

Example 16-17 JSON Structure of a Network Device

{
    “device”: {
      “interface”: “mgmt0”,
       “state”: “up”,
       “eth_ip_addr”: “192.168.10.175”,
       “eth_ip_mask”: 24,
                }
}

Both JSON and XML are human-readable formats. They are both independent of any specific programming language. However, there are a few differences:

Verbose: XML is more verbose than JSON and usually uses more characters to express the same data than JSON.

Arrays: XML is used to describe structured data, which doesn’t include arrays, whereas JSON includes arrays.

Parsing: Although most programming languages contain libraries that can parse both JSON and XML data, evaluating specific data elements can be more difficult in XML (although more powerful) compared to JSON.

Leave a Reply

Your email address will not be published. Required fields are marked *