On 2025-03-20 03:53, Saku Ytti via NANOG wrote:
On Thu, 20 Mar 2025 at 05:58, Jakob Heitz (jheitz) via NANOG
<nanog@lists.nanog.org> wrote:
XR has “show operational … json” or “… xml” commands. For example:
RP/0/0/CPU0:R5#show operational Interfaces InterfaceBriefTable InterfaceBrief/InterfaceName=GigabitEthernet0/0/0/0 json

I think it's important to also know that in Junos |display json|xml is
guaranteed, because CLI is not the 1st class citizen (except for some
PFE/shell commands, but most never use those once). CLi does XML RPC
calls and the structured XML data is the first-class citizen. There is
a static transform from the XML RPC into JSON, no one has to write any
code for JSON coverage of new commands.

Yes, all of this, but it's probably worth noting that there, at least in
the past, have been some JunOS management cli commands that just ran a
shell command and dumped the output, therefore not supporting "| display
json". A lot of the NTP commands used to be this way, though I think in
later releases they've updated that to support the json display on them.
Are there other commands that still do this? I'm personally not aware of
anything, but it's posslbe.

Additionally, that static transform into JSON from XML results in some
really horrendous json to work with. It is workable, but it's not fun.
This only applies to state data, the json rendering of config info "show
config ... | display json" is as you would expect. There is a config
switch that purports to output "compact" json for state commands, but it
generates (usually) invalid json (doesn't put lists into "[...]").

--
Jeff McAdams
_______________________________________________
NANOG mailing list https://lists.nanog.org/archives/list/nanog@lists.nanog.org/message/KV5ZLXAALMG4S7C75IL4R2PMNTT5OPLP/

Reply via email to