“imprimir JSON” Código de respuesta

Imprimir JSON Python

import json

uglyjson = '{"firstnam":"James","surname":"Bond","mobile":["007-700-007","001-007-007-0007"]}'

#json.load method converts JSON string to Python Object
parsed = json.loads(uglyjson)

print(json.dumps(parsed, indent=2, sort_keys=True))
Felipebros

Python Print Pretty Json


import json

json_data = '[{"ID":10,"Name":"Pankaj","Role":"CEO"},' \
            '{"ID":20,"Name":"David Lee","Role":"Editor"}]'

json_object = json.loads(json_data)

json_formatted_str = json.dumps(json_object, indent=2)

print(json_formatted_str)
Wide-eyed Wren

Python Escribir a Json con sangría

import json

# alphabetic dictionary
json_data = {hex(k): chr(k) for k in range(ord('a'), ord('z') + 1)}
# to file
with open("my_json.json", "w") as file:
    json.dump(json_data, file, indent=4, sort_keys=True)
jdam

Python JSON String to Object

import json

x =  '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)

print(y["age"]) 
Anxious Ant

Pretty Json Python

print(json.dumps(dict, indent=4))
Yucky Yacare

imprimir JSON

ObjectMapper mapper = new ObjectMapper();
String perttyStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
Clean Crossbill

Respuestas similares a “imprimir JSON”

Preguntas similares a “imprimir JSON”

Más respuestas relacionadas con “imprimir JSON” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código