Python Forum
CiscoConfParse to json output
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CiscoConfParse to json output
#4
why this printing on screen json format, however file dumps is not working.
dumping code

data = json.dumps(result, indent=4)
    s = json.dumps(data)
    open("out.json","w").write(s)
sample output

Output:
"{\n \"interfaces\": {\n \"Aux0/0/1\": {\n \"description\": \"not set\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \"n/a\"\n },\n \"Eth-Trunk1\": {\n \"description\": \"TO DEL-CON-S5328EI-SW-A5 Eth-Trunk2\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \"n/a\"\n },\n \"Eth-Trunk1.50\": {\n \"description\": \"not set\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \"n/a\"\n },\n \"Eth-Trunk1.103\": {\n \"description\": \"EXT_ILL_TTSL_Bhopal_5075509146\",\n \"qos-profile\": \" 6Mb outbound identifier none\",\n \"vlan-type\": \" dot1q 103\",\n \"address\": \"111.93.33.9\",\n \"netmask\": \"255.255.255.252\",\n \"network\": \"111.93.33.8/30\"\n },\n \"Eth-Trunk1.120\": {\n \"description\": \"EXT_COGENT E SERVICES PRIVATE LIMITED_12005744750_50MB\",\n \"qos-profile\": \" 50Mbps outbound identifier none\",\n \"vlan-type\": \" dot1q 120\",\n \"address\": \"111.93.43.217\",\n \"netmask\": \"255.255.255.252\",\n \"network\": \"111.93.43.216/30\"\n },\n \"Eth-Trunk1.123\": {\n \"description\": \"EXT_ILL_SARALA-HANDICRAFTS_PANIPAT_5018027739\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \" dot1q 123\",\n \"address\": \"182.156.211.161\",\n \"netmask\": \"255.255.255.252\",\n \"network\": \"182.156.211.160/30\"\n },\n \"Eth-Trunk1.128\": {\n \"description\": \"EXT_LIVEDIGITAL MARKETING SOLUTION PRIVATE LIMITED_12005725741\",\n \"qos-profile\": \" 4Mb outbound identifier none\",\n \"vlan-type\": \" dot1q 128\",\n \"address\": \"111.93.127.81\",\n \"netmask\": \"255.255.255.248\",\n \"network\": \"111.93.127.80/29\"\n },\n \"Eth-Trunk1.130\": {\n \"description\": \"EXT_MISUMI INDIA PVT LTD_12405738282\",\n \"qos-profile\": \" 30Mb outbound identifier none\",\n \"vlan-type\": \" dot1q 130\",\n \"address\": \"111.93.33.201\",\n \"netmask\": \"255.255.255.248\",\n \"network\": \"111.93.33.200/29\"\n },\n \"Eth-Trunk1.155\": {\n \"description\": \"EXT_IREO-12405068279\",\n \"qos-profile\": \" Internet_8Mb outbound identifier none\",\n \"vlan-type\": \" dot1q 155\",\n \"address\": \"111.93.232.221\",\n \"netmask\": \"255.255.255.252\",\n \"network\": \"111.93.232.220/30\"\n },\n \"Eth-Trunk1.157\": {\n \"description\": \"not set\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \"n/a\"\n },\n \"Eth-Trunk1.158\": {\n \"description\": \"EXT_MATHWORKS INDIA PRIVATE LIMITED_1105725697\",\n \"qos-profile\": \" 10Mb outbound identifier none\",\n \"vlan-type\": \" dot1q 158\",\n \"address\": \"111.93.206.33\",\n \"netmask\": \"255.255.255.252\",\n \"network\": \"111.93.206.32/30\"\n },\n \"Eth-Trunk1.168\": {\n \"description\": \"not set\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \"n/a\"\n },\n \"Eth-Trunk1.170\": {\n \"description\": \"EXT_NATIONAL HIGHWAYS AND INFRASTRUCTURE DEVE CORP LTD_1105722482\",\n \"qos-profile\": \"n/a\",\n \"vlan-type\": \" dot1q 170\",\n \"address\": \"111.93.193.141\",\n \"netmask\": \"255.255.255.252\",\n \"network\": \"111.93.193.140/30\"\n },\n
Reply


Messages In This Thread
CiscoConfParse to json output - by anna - Feb-06-2019, 01:35 PM
RE: CiscoConfParse to json output - by scidam - Feb-07-2019, 12:13 PM
RE: CiscoConfParse to json output - by anna - Feb-07-2019, 04:26 PM
RE: CiscoConfParse to json output - by anna - Feb-08-2019, 12:20 PM
RE: CiscoConfParse to json output - by scidam - Feb-09-2019, 11:45 AM
RE: CiscoConfParse to json output - by anna - Feb-09-2019, 05:18 PM
RE: CiscoConfParse to json output - by anna - Feb-12-2019, 10:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  geojson to json --missing multiple row output yoshi 9 3,023 Mar-06-2022, 08:34 PM
Last Post: snippsat
  json.dumps list output qurr 12 5,426 Apr-08-2020, 10:13 PM
Last Post: micseydel
  json.dumps output error in python3 prayuktibid 2 2,759 Jan-21-2020, 06:41 AM
Last Post: prayuktibid
  Output to a json file problem Netcode 3 3,840 Nov-22-2019, 01:44 AM
Last Post: Skaperen
  Make a table from a json output carstenlp 13 26,521 Jan-12-2019, 09:06 PM
Last Post: carstenlp
  Unable to parse JSON output dragan979 1 3,617 Apr-20-2018, 02:24 PM
Last Post: dragan979

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020