json2pyi
1.0.0
json2pyi infiere un esquema de tipo a partir de un archivo JSON de muestra y genera definiciones de tipo de Python ( dataclass
, Pydantic BaseModel
o PEP-589 TypedDict
) en consecuencia. Se ejecuta en el navegador y no requiere instalación.
¿Disponible en línea? : https://json2pyi.pages.dev
Aporte:
{
"page" : {
"id" : "kctbh9vrtdwd" ,
"name" : "GitHub" ,
"url" : "https://www.githubstatus.com" ,
"time_zone" : "Etc/UTC" ,
"updated_at" : "2020-12-03T08:11:21.385Z"
} ,
"components" : [
{
"id" : "8l4ygp009s5s" ,
"name" : "Git Operations" ,
"status" : "operational" ,
"created_at" : "2017-01-31T20:05:05.370Z" ,
"updated_at" : "2020-10-29T22:51:43.831Z" ,
"position" : 1 ,
"description" : "Performance of git clones, pulls, pushes, and associated operations" ,
"showcase" : false ,
"start_date" : null ,
"group_id" : null ,
"page_id" : "kctbh9vrtdwd" ,
"group" : false ,
"only_show_if_degraded" : false
} ,
/* ... */
] ,
"incidents" : [ ] ,
"scheduled_maintenances" : [ ] ,
"status" : {
"indicator" : "none" ,
"description" : "All Systems Operational"
}
}
Producción:
@ dataclass
class Page :
id = str
name = str
url = str
time_zone = str
updated_at = str
@ dataclass
class Components :
id = str
name = str
status = str
created_at = str
updated_at = str
position = int
description = Optional [ str ]
showcase = bool
start_date = None
group_id = None
page_id = str
group = bool
only_show_if_degraded = bool
@ dataclass
class Status :
indicator = str
description = str
@ dataclass
class RootObject :
page = Page
components = List [ Components ]
incidents = List [ Any ]
scheduled_maintenances = List [ Any ]
status = Status
O:
from typing import TypedDict , Optional , List
from datetime import datetime
IncidentUpdate = TypedDict ( "IncidentUpdate" , { "body" : str , "created_at" : datetime , "display_at" : datetime , "id" : str , "incident_id" : str , "status" : str , "updated_at" : datetime })
IncidentOrScheduledMaintenance = TypedDict ( "IncidentOrScheduledMaintenance" , { "created_at" : datetime , "id" : str , "impact" : str , "incident_updates" : List [ IncidentUpdate ], "monitoring_at" : None , "name" : str , "page_id" : str , "resolved_at" : None , "shortlink" : str , "status" : str , "updated_at" : datetime , "scheduled_for" : Optional [ datetime ], "scheduled_until" : Optional [ datetime ]})
Component = TypedDict ( "Component" , { "created_at" : datetime , "description" : None , "id" : str , "name" : str , "page_id" : str , "position" : int , "status" : str , "updated_at" : datetime })
Status = TypedDict ( "Status" , { "description" : str , "indicator" : str })
Page = TypedDict ( "Page" , { "id" : str , "name" : str , "url" : str , "updated_at" : datetime })
RootObject = TypedDict ( "UnnammedType3C2BC8" , { "page" : Page , "status" : Status , "components" : List [ Component ], "incidents" : List [ IncidentOrScheduledMaintenance ], "scheduled_maintenances" : List [ IncidentOrScheduledMaintenance ]})
El proyecto está inspirado en: