- play_arrow Manage Junos XML Protocol Sessions
- play_arrow Junos XML Protocol Session Overview
- play_arrow Manage Junos XML Protocol Sessions
- Satisfy the Prerequisites for Establishing a Connection to the Junos XML Protocol Server
- Configure clear-text or SSL Service for Junos XML Protocol Client Applications
- Connect to the Junos XML Protocol Server
- Start a Junos XML Protocol Session
- Authenticate with the Junos XML Protocol Server for Cleartext or SSL Connections
- Send Requests to the Junos XML Protocol Server
- Parse the Junos XML Protocol Server Response
- Parse Response Tag Elements Using a Standard API in NETCONF and Junos XML Protocol Sessions
- How Character Encoding Works on Juniper Networks Devices
- Handle an Error or Warning in Junos XML Protocol Sessions
- Halt a Request in Junos XML Protocol Sessions
- Lock, Unlock, or Create a Private Copy of the Candidate Configuration Using the Junos XML Protocol
- Terminate a Junos XML Protocol Session
- End a Junos XML Protocol Session and Close the Connection
- Sample Junos XML Protocol Session
- play_arrow Junos XML Protocol Tracing Operations
- play_arrow Junos XML Protocol Operations
- play_arrow Junos XML Protocol Processing Instructions
- play_arrow Junos XML Protocol Response Tags
- play_arrow Junos XML Element Attributes
- active
- count
- delete
- inactive
- insert
- junos:changed
- junos:changed-localtime
- junos:changed-seconds
- junos:commit-localtime
- junos:commit-seconds
- junos:commit-user
- junos:group
- junos:interface-range
- junos:key
- junos:position
- junos:total
- matching
- protect
- recurse
- rename
- replace
- replace-pattern
- start
- unprotect
- xmlns
-
- play_arrow Manage Configurations Using the Junos XML Protocol
- play_arrow Change the Configuration Using the Junos XML Protocol
- Request Configuration Changes Using the Junos XML Protocol
- Upload and Format Configuration Data in a Junos XML Protocol Session
- Upload Configuration Data as a File Using the Junos XML Protocol
- Upload Configuration Data as a Data Stream Using the Junos XML Protocol
- Define the Format of Configuration Data to Upload in a Junos XML Protocol Session
- Specify the Scope of Configuration Data to Upload in a Junos XML Protocol Session
- Replace the Configuration Using the Junos XML Protocol
- Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol
- Create New Elements in Configuration Data Using the Junos XML Protocol
- Merge Elements in Configuration Data Using the Junos XML Protocol
- Replace Elements in Configuration Data Using the Junos XML Protocol
- Replace Only Updated Elements in Configuration Data Using the Junos XML Protocol
- Delete Elements in Configuration Data Using the Junos XML Protocol
- Rename Objects In Configuration Data Using the Junos XML Protocol
- Reorder Elements In Configuration Data Using the Junos XML Protocol
- Protect or Unprotect a Configuration Object Using the Junos XML Protocol
- Change a Configuration Element’s Activation State Using the Junos XML Protocol
- Change a Configuration Element’s Activation State Simultaneously with Other Changes Using the Junos XML Protocol
- Replace Patterns in Configuration Data Using the NETCONF or Junos XML Protocol
- play_arrow Commit the Configuration on a Device Using the Junos XML Protocol
- Verify Configuration Syntax Using the Junos XML Protocol
- Commit the Candidate Configuration Using the Junos XML Protocol
- Commit a Private Copy of the Configuration Using the Junos XML Protocol
- Commit a Configuration at a Specified Time Using the Junos XML Protocol
- Commit the Candidate Configuration Only After Confirmation Using the Junos XML Protocol
- Commit and Synchronize a Configuration on Redundant Control Planes Using the Junos XML Protocol
- Log a Message About a Commit Operation Using the Junos XML Protocol
- View the Configuration Revision Identifier for Determining Synchronization Status of Devices with NMS
- play_arrow Ephemeral Configuration Database
- Understanding the Ephemeral Configuration Database
- Unsupported Configuration Statements in the Ephemeral Configuration Database
- Enable and Configure Instances of the Ephemeral Configuration Database
- Commit and Synchronize Ephemeral Configuration Data Using the NETCONF or Junos XML Protocol
- Managing Ephemeral Configuration Database Space
-
- play_arrow Request Operational and Configuration Information Using the Junos XML Protocol
- play_arrow Request Operational Information Using the Junos XML Protocol
- play_arrow Request Configuration Information Using the Junos XML Protocol
- Request Configuration Data Using the Junos XML Protocol
- Specify the Source for Configuration Information Requests in a Junos XML Protocol Session
- Specify the Output Format for Configuration Data in a Junos XML Protocol Session
- Request Commit-Script-Style XML Configuration Data Using the Junos XML Protocol
- Specify the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocol
- Request Identifier Indicators for Configuration Elements Using the Junos XML Protocol
- Request Change Indicators for Configuration Elements Using the Junos XML Protocol
- Specify the Scope of Configuration Data to Return in a Junos XML Protocol Session
- Request the Complete Configuration Using the Junos XML Protocol
- Request a Configuration Hierarchy Level or Container Object Without an Identifier Using the Junos XML Protocol
- Request All Configuration Objects of a Specific Type Using the Junos XML Protocol
- Request a Specific Number of Configuration Objects Using the Junos XML Protocol
- Request Identifiers for Configuration Objects of a Specific Type Using the Junos XML Protocol
- Request a Single Configuration Object Using the Junos XML Protocol
- Request Subsets of Configuration Objects Using Regular Expressions
- Request Multiple Configuration Elements Using the Junos XML Protocol
- Retrieve a Previous (Rollback) Configuration Using the Junos XML Protocol
- Retrieve the Rescue Configuration Using the Junos XML Protocol
- Compare the Active or Candidate Configuration to a Prior Version Using the Junos XML Protocol
- Compare Two Previous (Rollback) Configurations Using the Junos XML Protocol
- Request an XML Schema for the Configuration Hierarchy Using the Junos XML Protocol
-
- play_arrow Junos XML Protocol Utilities
- play_arrow Develop Junos XML Protocol C Client Applications
-
- play_arrow Configuration Statements and Operational Commands
Map Junos OS Command Output to JSON in the CLI
The Junos® operating system (Junos OS) natively supports XML for the operation and configuration of Junos devices, and the Junos OS CLI and the Junos OS infrastructure communicate using XML. When you issue an operational command or display the configuration in the CLI, the CLI converts the output from XML into a readable text format for display.
Junos devices also support a JavaScript Object Notation (JSON) representation of the
operational command output and the configuration hierarchy. To display the command
output or configuration in JSON instead of in the default formatted ASCII text,
append the | display json
option to the command in the CLI.
The following example executes the show chassis hardware
command
and displays the output in JSON format. The response is identical to the NETCONF or
Junos XML protocol server response for the <get-chassis-inventory
format="json">
RPC request.
user@host> show chassis hardware | display json { "chassis-inventory" : [ { "attributes" : { "xmlns" : "http://xml.juniper.net/junos/16.1R1/junos-chassis" }, "chassis" : [ { "attributes" : {"junos:style" : "inventory"}, "name" : [ { "data" : "Chassis" } ], "serial-number" : [ { "data" : "serial-number" } ], "description" : [ { "data" : "MX80-48T" } ], "chassis-module" : [ { "name" : [ { "data" : "Midplane" } ], "version" : [ { "data" : "REV 11" } ], "part-number" : [ { "data" : "711-031603" } ], "serial-number" : [ { "data" : "serial-number" } ], "description" : [ { "data" : "MX80-48T" } ], "clei-code" : [ { "data" : "CMMAX10BRD" } ], "model-number" : [ { "data" : "CHAS-MX80-48T-S" } ] }, //* additional JSON objects *// ] } ] } ] }
Starting in Junos OS Release 16.1, Junos OS uses a new default implementation for
serialization for configuration data emitted in JSON format. The new default,
ietf
, is as defined in the following Internet drafts:
draft-ietf-netmod-yang-json-09, JSON Encoding of Data Modeled with YANG
draft-ietf-netmod-yang-metadata-06, Defining and Using Metadata with YANG
In earlier releases, the default is verbose
, which emits all objects
as JSON arrays. You can configure the default export format for JSON configuration
data by configuring the appropriate statement at the [edit system
export-format json]
hierarchy level.
By default, Junos devices emit JSON-formatted state data in non-compact format, which
emits all objects as JSON arrays. In Junos OS Release 24.2 and earlier and Junos OS
Evolved Release 24.2 and earlier, Junos devices support emitting the device’s state
data in compact JSON format, in which only objects that have multiple values are
emitted as JSON arrays. To configure the device to emit compact JSON format,
configure the compact
statement at the [edit system
export-format state-data json]
hierarchy level.
user@host# set system export-format state-data json compact
The following example executes the show system uptime
command and
displays the output in both non-compact and compact JSON format.
user@host> show system uptime | display json
The following output shows the non-compact JSON format:
{ "system-uptime-information" : [ { "attributes" : {"xmlns" : "http://xml.juniper.net/junos/18.1R1/junos"}, "current-time" : [ { "date-time" : [ { "data" : "2018-05-15 13:43:46 PDT", "attributes" : {"junos:seconds" : "1526417026"} } ] } ], "time-source" : [ { "data" : " NTP CLOCK " } ], "system-booted-time" : [ { "date-time" : [ { "data" : "2018-05-15 10:57:02 PDT", "attributes" : {"junos:seconds" : "1526407022"} } ], "time-length" : [ { "data" : "02:46:44", "attributes" : {"junos:seconds" : "10004"} } ] } ], "protocols-started-time" : [ { "date-time" : [ { "data" : "2018-05-15 10:59:33 PDT", "attributes" : {"junos:seconds" : "1526407173"} } ], "time-length" : [ { "data" : "02:44:13", "attributes" : {"junos:seconds" : "9853"} } ] } ], "last-configured-time" : [ { "date-time" : [ { "data" : "2018-05-02 17:57:44 PDT", "attributes" : {"junos:seconds" : "1525309064"} } ], "time-length" : [ { "data" : "1w5d 19:46", "attributes" : {"junos:seconds" : "1107962"} } ], "user" : [ { "data" : "admin" } ] } ], "uptime-information" : [ { "date-time" : [ { "data" : "1:43PM", "attributes" : {"junos:seconds" : "1526417026"} } ], "up-time" : [ { "data" : "2:47", "attributes" : {"junos:seconds" : "10034"} } ], "active-user-count" : [ { "data" : "1", "attributes" : {"junos:format" : "1 user"} } ], "load-average-1" : [ { "data" : "0.49" } ], "load-average-5" : [ { "data" : "0.19" } ], "load-average-15" : [ { "data" : "0.10" } ] } ] } ] }
The output for the same command in compact JSON format is:
{ "system-uptime-information" : { "current-time" : { "date-time" : "2018-05-15 13:49:56 PDT" }, "time-source" : " NTP CLOCK ", "system-booted-time" : { "date-time" : "2018-05-15 10:57:02 PDT", "time-length" : "02:52:54" }, "protocols-started-time" : { "date-time" : "2018-05-15 10:59:33 PDT", "time-length" : "02:50:23" }, "last-configured-time" : { "date-time" : "2018-05-15 13:49:40 PDT", "time-length" : "00:00:16", "user" : "admin" }, "uptime-information" : { "date-time" : "1:49PM", "up-time" : "2:53", "active-user-count" : "1", "load-average-1" : "0.00", "load-average-5" : "0.06", "load-average-15" : "0.06" } } }
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.
compact
statement at the
[edit system export-format state-data json]
hierarchy
level.