1

We need to convert Juniper config to json is there any Juniper command for this or how should we write a small ruby code to convert default juniper config into json.

Navdeep
  • 11
  • 1
  • 3

4 Answers4

1

After Junos release 14.2, show config | display json command is available. http://www.juniper.net/techpubs/en_US/junos14.2/topics/concept/junos-cli-pipe-filter-functions-overview.html

kazubu
  • 11
  • 1
0

AFAIK there is no command to convert to JSON, but perhaps you could read it in XML format then convert the XML to JSON using Ruby?

JunOS

show configuration | display xml

Ruby

Hash.from_xml('...').to_json
Mark-K
  • 126
  • 1
  • 5
0

In case anybody is looking: https://beastiebytes.com/public_files/juniper_hash.rb

require 'json'
require 'juniper_hash'
JuniperHash.get_hash(File.open('juniper.conf').read).to_json
sven
  • 1
0

In configuration mode you can do this : show |display json

If you want to store it in a file show |display json |save file.cfg