Feb-08-2019, 12:20 PM
why this printing on screen json format, however file dumps is not working.
dumping code
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