- play_arrow Overview
- play_arrow Junos XML Management Protocol and Junos XML API Overview
- play_arrow Junos XML Protocol and Junos XML Tags Overview
- XML and Junos OS Overview
- XML Overview
- XML and Junos XML Management Protocol Conventions Overview
- Map Junos OS Commands and Command Output to Junos XML Tag Elements
- Map Configuration Statements to Junos XML Tag Elements
- Using Configuration Response Tag Elements in Junos XML Protocol Requests and Configuration Changes
- play_arrow Junos XML Protocol and JSON Overview
-
- 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 Junos XML Protocol Utilities
- play_arrow Develop Junos XML Protocol C Client Applications
-
- play_arrow Configuration Statements and Operational Commands
Specify the Output Format for Operational Information Requests in a Junos XML Protocol Session
In a Junos XML protocol session, to request information about a Junos device, a
client application emits an <rpc>
element that encloses a
Junos XML request tag element. To request that the Junos XML protocol server return
the output in a specific format, the client application includes the optional
format
attribute in the opening operational request tag. The
application can request output in formatted ASCII text, JavaScript Object Notation
(JSON), or XML-tagged format. The basic syntax is as follows:
<rpc> <operational-request format="(ascii | json | text | xml)"> <!-- tag elements for options --> </operational-request> </rpc>
XML Format
By default, the Junos XML protocol server returns operational information in XML
format. If the format
attribute is set to xml
, or
if the format
attribute is omitted, the server returns the response
in XML. The following example requests information for the ge-0/3/0 interface and
omits the format
attribute.
<rpc> <get-interface-information> <brief/> <interface-name>ge-0/3/0</interface-name> </get-interface-information> </rpc>
The Junos XML protocol server returns the information in XML, which is identical to
the output displayed in the CLI when you include the | display xml
option after the operational mode command.
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.4R1/junos"> <interface-information xmlns="http://xml.juniper.net/junos/11.4R1/junos-interface" junos:style="brief"> <physical-interface> <name>ge-0/3/0</name> <admin-status junos:format="Enabled">up</admin-status> <oper-status>down</oper-status> <link-level-type>Ethernet</link-level-type> <mtu>1514</mtu> <source-filtering>disabled</source-filtering> <speed>1000mbps</speed> <bpdu-error>none</bpdu-error> <l2pt-error>none</l2pt-error> <loopback>disabled</loopback> <if-flow-control>enabled</if-flow-control> <if-auto-negotiation>enabled</if-auto-negotiation> <if-remote-fault>online</if-remote-fault> <if-device-flags> <ifdf-present/> <ifdf-running/> <ifdf-down/> </if-device-flags> <if-config-flags> <iff-hardware-down/> <iff-snmp-traps/> <internal-flags>0x4000</internal-flags> </if-config-flags> <if-media-flags> <ifmf-none/> </if-media-flags> </physical-interface> </interface-information> </rpc-reply>
ASCII Format
To request that the Junos XML protocol server return operational information as
formatted ASCII text instead of tagging it with Junos XML tag elements, the client
application includes the format="text"
or
format="ascii"
attribute in the opening request tag.
<rpc> <get-interface-information format="(text | ascii)"> <brief/> <interface-name>ge-0/3/0</interface-name> </get-interface-information> </rpc>
When the client application includes the format="text"
or
format="ascii"
attribute in the request tag, the Junos XML
protocol server formats the reply as ASCII text and encloses it in an
<output>
tag element. The format="text"
and format="ascii"
attributes produce identical output.
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.4R1/junos"> <output> Physical interface: ge-0/3/0, Enabled, Physical link is Down Link-level type: Ethernet, MTU: 1514, Speed: 1000mbps, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online Device flags : Present Running Down Interface flags: Hardware-Down SNMP-Traps Internal: 0x4000 Link flags : None </output> </rpc-reply>
The following example shows the equivalent operational mode command executed in the CLI:
user@host> show interfaces ge-0/3/0 brief Physical interface: ge-0/3/0, Enabled, Physical link is Down Link-level type: Ethernet, MTU: 1514, Speed: 1000mbps, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online Device flags : Present Running Down Interface flags: Hardware-Down SNMP-Traps Internal: 0x4000 Link flags : None
The formatted ASCII text returned by the Junos XML protocol server is identical to the CLI output except in cases where the output includes disallowed characters such as '<' (less-than sign), '>' (greater-than sign), and '&' (ampersand). The Junos XML protocol server substitutes these characters with the equivalent predefined entity reference of '<', '>', and '&' respectively.
If the Junos XML API does not define a response tag element for the type of output
requested by a client application, the Junos XML protocol server returns the reply
as formatted ASCII text enclosed in an <output>
tag element
even if XML-tagged output is requested.
The content and formatting of data within an <output>
tag
element are subject to change, so client applications must not depend on
them.
JSON Format
A client application can request operational and configuration information in JSON
format. To request that the Junos XML protocol server return operational information
in JSON format, the client application includes the format="json"
attribute in the opening request tag.
<rpc> <get-interface-information format="json"> <brief/> <interface-name>cbp0</interface-name> </get-interface-information> </rpc>
When the client application includes the format="json"
attribute in
the request tag, the Junos XML protocol server formats the reply using JSON.
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1R1/junos"> { "interface-information" : [ { "attributes" : {"xmlns" : "http://xml.juniper.net/junos/16.1R1/junos-interface", "junos:style" : "brief" }, "physical-interface" : [ { "name" : [ { "data" : "cbp0" } ], "admin-status" : [ { "data" : "up", "attributes" : {"junos:format" : "Enabled"} } ], "oper-status" : [ { "data" : "up" } ], "if-type" : [ { "data" : "Ethernet" } ], "link-level-type" : [ { "data" : "Ethernet" } ], "mtu" : [ { "data" : "1514" } ], "speed" : [ { "data" : "Unspecified" } ], "clocking" : [ { "data" : "Unspecified" } ], "if-device-flags" : [ { "ifdf-present" : [ { "data" : [null] } ], "ifdf-running" : [ { "data" : [null] } ] } ], "ifd-specific-config-flags" : [ { "internal-flags" : [ { "data" : "0x0" } ] } ], "if-config-flags" : [ { "iff-snmp-traps" : [ { "data" : [null] } ] } ] } ] } ] } </rpc-reply>
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
operational state 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 | display json
command and displays the output in non-compact and compact JSON format.
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" } ] } ] } ] }
Compact JSON format:
{ "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.