Python JSON template beautify predložak

podaci.json

{
  "servers" : [
    {
      "name"       : "Jednostavno-HTML",
      "description": "Provjeri HTML - Jednostavno",
      "deviceName" : "https://jednostavno.somware.org",
      "type"       : "lynx",
      "port"       : 0
    },
    {
      "name"       : "Misli-pingaj",
      "description": "Provjeri pingabilnost Misli",
      "deviceName" : "misli.somware.org",
      "type"       : "ping",
      "port"       : 0
    },
    {
      "name"       : "Server4-SSH",
      "description": "Server 4 - Provjeri SSH",
      "deviceName" : "192.168.1.4",
      "type"       : "telnet",
      "port"       : 22
    }
  ]
}

python.py – Čitaj JSON

podaci = open("podaci.json", "r" , encoding="UTF-8")
jsonData = json.load(podaci)
for podatak in jsonData["servers"]:
  print(podatak)
  print(podatak["name"])
Rezultat

python.py beautify

import json
print ( json.dumps ( nekiJsonString , indent=4 ) )
print ( json.dumps ( nekiJsonString ["LijevaStrana"], indent=4 ) )

xpython xjson xread xčitaj xcitaj xotvori xopen xdisplay xprikaži display prikazi beautify xbeautify bjuti xbjuti

image_pdfimage_print