[{"data":1,"prerenderedAt":801},["ShallowReactive",2],{"post-/blog/json-to-python-class":3,"related-/blog/json-to-python-class":200},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"keywords":12,"body":16,"_type":194,"_id":195,"_source":196,"_file":197,"_stem":198,"_extension":199},"/blog/json-to-python-class","blog",false,"","JSON 转 Python 类教程","根据 JSON 生成 Python dataclass 或 Pydantic 模型，用于 Python 后端建模。","2026-08-19","代码生成",[13,14,15],"json转python","json to pydantic","python dataclass",{"type":17,"children":18,"toc":186},"root",[19,27,33,39,44,50,55,60,143,148,170,175,180],{"type":20,"tag":21,"props":22,"children":24},"element","h1",{"id":23},"json-转-python-类教程",[25],{"type":26,"value":8},"text",{"type":20,"tag":28,"props":29,"children":30},"p",{},[31],{"type":26,"value":32},"根据 JSON 生成 Python dataclass 或 Pydantic 模型，用于 Python 后端数据校验与建模。",{"type":20,"tag":34,"props":35,"children":37},"h2",{"id":36},"类型映射",[38],{"type":26,"value":36},{"type":20,"tag":28,"props":40,"children":41},{},[42],{"type":26,"value":43},"string→str、number→int/float、boolean→bool、array→list、object→嵌套类。",{"type":20,"tag":34,"props":45,"children":47},{"id":46},"pydantic-优势",[48],{"type":26,"value":49},"Pydantic 优势",{"type":20,"tag":28,"props":51,"children":52},{},[53],{"type":26,"value":54},"Pydantic 提供运行时类型校验，适合 API 模型。",{"type":20,"tag":34,"props":56,"children":58},{"id":57},"代码示例",[59],{"type":26,"value":57},{"type":20,"tag":61,"props":62,"children":66},"pre",{"className":63,"code":64,"language":65,"meta":7,"style":7},"language-json shiki shiki-themes github-dark","{\"id\": 1, \"name\": \"x\", \"tags\": [\"a\"]}\n","json",[67],{"type":20,"tag":68,"props":69,"children":70},"code",{"__ignoreMap":7},[71],{"type":20,"tag":72,"props":73,"children":76},"span",{"class":74,"line":75},"line",1,[77,83,89,94,99,104,109,113,119,123,128,133,138],{"type":20,"tag":72,"props":78,"children":80},{"style":79},"--shiki-default:#E1E4E8",[81],{"type":26,"value":82},"{",{"type":20,"tag":72,"props":84,"children":86},{"style":85},"--shiki-default:#79B8FF",[87],{"type":26,"value":88},"\"id\"",{"type":20,"tag":72,"props":90,"children":91},{"style":79},[92],{"type":26,"value":93},": ",{"type":20,"tag":72,"props":95,"children":96},{"style":85},[97],{"type":26,"value":98},"1",{"type":20,"tag":72,"props":100,"children":101},{"style":79},[102],{"type":26,"value":103},", ",{"type":20,"tag":72,"props":105,"children":106},{"style":85},[107],{"type":26,"value":108},"\"name\"",{"type":20,"tag":72,"props":110,"children":111},{"style":79},[112],{"type":26,"value":93},{"type":20,"tag":72,"props":114,"children":116},{"style":115},"--shiki-default:#9ECBFF",[117],{"type":26,"value":118},"\"x\"",{"type":20,"tag":72,"props":120,"children":121},{"style":79},[122],{"type":26,"value":103},{"type":20,"tag":72,"props":124,"children":125},{"style":85},[126],{"type":26,"value":127},"\"tags\"",{"type":20,"tag":72,"props":129,"children":130},{"style":79},[131],{"type":26,"value":132},": [",{"type":20,"tag":72,"props":134,"children":135},{"style":115},[136],{"type":26,"value":137},"\"a\"",{"type":20,"tag":72,"props":139,"children":140},{"style":79},[141],{"type":26,"value":142},"]}\n",{"type":20,"tag":34,"props":144,"children":146},{"id":145},"推荐在线工具",[147],{"type":26,"value":145},{"type":20,"tag":149,"props":150,"children":151},"ul",{},[152,162],{"type":20,"tag":153,"props":154,"children":155},"li",{},[156],{"type":20,"tag":157,"props":158,"children":160},"a",{"href":159},"/codegen/java",[161],{"type":26,"value":159},{"type":20,"tag":153,"props":163,"children":164},{},[165],{"type":20,"tag":157,"props":166,"children":168},{"href":167},"/format",[169],{"type":26,"value":167},{"type":20,"tag":34,"props":171,"children":173},{"id":172},"小结",[174],{"type":26,"value":172},{"type":20,"tag":28,"props":176,"children":177},{},[178],{"type":26,"value":179},"根据 JSON 生成 Python dataclass 或 Pydantic 模型，用于 Python 后端建模。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":181,"props":182,"children":183},"style",{},[184],{"type":26,"value":185},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":187,"depth":187,"links":188},2,[189,190,191,192,193],{"id":36,"depth":187,"text":36},{"id":46,"depth":187,"text":49},{"id":57,"depth":187,"text":57},{"id":145,"depth":187,"text":145},{"id":172,"depth":187,"text":172},"markdown","content:blog:json-to-python-class.md","content","blog/json-to-python-class.md","blog/json-to-python-class","md",[201,353,528,670],{"_path":202,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":203,"description":204,"date":10,"category":11,"keywords":205,"body":209,"_type":194,"_id":350,"_source":196,"_file":351,"_stem":352,"_extension":199},"/blog/json-to-csharp-class","JSON 转 C# 类教程","根据 JSON 生成 C# 类，用于 .NET 后端快速建模与反序列化。",[206,207,208],"json转csharp","json to c#","csharp class",{"type":17,"children":210,"toc":343},[211,216,221,225,230,235,240,244,309,313,330,334,339],{"type":20,"tag":21,"props":212,"children":214},{"id":213},"json-转-c-类教程",[215],{"type":26,"value":203},{"type":20,"tag":28,"props":217,"children":218},{},[219],{"type":26,"value":220},"根据 JSON 生成 C# 类定义，自动推断属性类型，用于 .NET 序列化建模。",{"type":20,"tag":34,"props":222,"children":223},{"id":36},[224],{"type":26,"value":36},{"type":20,"tag":28,"props":226,"children":227},{},[228],{"type":26,"value":229},"string→string、number→int/double、boolean→bool、array→List、object→嵌套类。",{"type":20,"tag":34,"props":231,"children":233},{"id":232},"使用建议",[234],{"type":26,"value":232},{"type":20,"tag":28,"props":236,"children":237},{},[238],{"type":26,"value":239},"可配合 Newtonsoft.Json 或 System.Text.Json 使用。",{"type":20,"tag":34,"props":241,"children":242},{"id":57},[243],{"type":26,"value":57},{"type":20,"tag":61,"props":245,"children":247},{"className":63,"code":246,"language":65,"meta":7,"style":7},"{\"id\": 1, \"name\": \"x\", \"price\": 9.9}\n",[248],{"type":20,"tag":68,"props":249,"children":250},{"__ignoreMap":7},[251],{"type":20,"tag":72,"props":252,"children":253},{"class":74,"line":75},[254,258,262,266,270,274,278,282,286,290,295,299,304],{"type":20,"tag":72,"props":255,"children":256},{"style":79},[257],{"type":26,"value":82},{"type":20,"tag":72,"props":259,"children":260},{"style":85},[261],{"type":26,"value":88},{"type":20,"tag":72,"props":263,"children":264},{"style":79},[265],{"type":26,"value":93},{"type":20,"tag":72,"props":267,"children":268},{"style":85},[269],{"type":26,"value":98},{"type":20,"tag":72,"props":271,"children":272},{"style":79},[273],{"type":26,"value":103},{"type":20,"tag":72,"props":275,"children":276},{"style":85},[277],{"type":26,"value":108},{"type":20,"tag":72,"props":279,"children":280},{"style":79},[281],{"type":26,"value":93},{"type":20,"tag":72,"props":283,"children":284},{"style":115},[285],{"type":26,"value":118},{"type":20,"tag":72,"props":287,"children":288},{"style":79},[289],{"type":26,"value":103},{"type":20,"tag":72,"props":291,"children":292},{"style":85},[293],{"type":26,"value":294},"\"price\"",{"type":20,"tag":72,"props":296,"children":297},{"style":79},[298],{"type":26,"value":93},{"type":20,"tag":72,"props":300,"children":301},{"style":85},[302],{"type":26,"value":303},"9.9",{"type":20,"tag":72,"props":305,"children":306},{"style":79},[307],{"type":26,"value":308},"}\n",{"type":20,"tag":34,"props":310,"children":311},{"id":145},[312],{"type":26,"value":145},{"type":20,"tag":149,"props":314,"children":315},{},[316,323],{"type":20,"tag":153,"props":317,"children":318},{},[319],{"type":20,"tag":157,"props":320,"children":321},{"href":159},[322],{"type":26,"value":159},{"type":20,"tag":153,"props":324,"children":325},{},[326],{"type":20,"tag":157,"props":327,"children":328},{"href":167},[329],{"type":26,"value":167},{"type":20,"tag":34,"props":331,"children":332},{"id":172},[333],{"type":26,"value":172},{"type":20,"tag":28,"props":335,"children":336},{},[337],{"type":26,"value":338},"根据 JSON 生成 C# 类，用于 .NET 后端快速建模与反序列化。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":181,"props":340,"children":341},{},[342],{"type":26,"value":185},{"title":7,"searchDepth":187,"depth":187,"links":344},[345,346,347,348,349],{"id":36,"depth":187,"text":36},{"id":232,"depth":187,"text":232},{"id":57,"depth":187,"text":57},{"id":145,"depth":187,"text":145},{"id":172,"depth":187,"text":172},"content:blog:json-to-csharp-class.md","blog/json-to-csharp-class.md","blog/json-to-csharp-class",{"_path":354,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":355,"description":356,"date":10,"category":11,"keywords":357,"body":361,"_type":194,"_id":525,"_source":196,"_file":526,"_stem":527,"_extension":199},"/blog/json-to-excel","JSON 转 Excel 教程","将 JSON 数据导出为 Excel xlsx 文件，用于数据分析与报表。",[358,359,360],"json转excel","json to xlsx","导出excel",{"type":17,"children":362,"toc":518},[363,368,373,378,383,388,393,397,482,486,505,509,514],{"type":20,"tag":21,"props":364,"children":366},{"id":365},"json-转-excel-教程",[367],{"type":26,"value":355},{"type":20,"tag":28,"props":369,"children":370},{},[371],{"type":26,"value":372},"将 JSON 数组导出为 Excel xlsx 文件，键作为列名，用于数据分析与报表分发。",{"type":20,"tag":34,"props":374,"children":376},{"id":375},"转换条件",[377],{"type":26,"value":375},{"type":20,"tag":28,"props":379,"children":380},{},[381],{"type":26,"value":382},"JSON 须为对象数组，每个对象的键作为列，值作为单元格。",{"type":20,"tag":34,"props":384,"children":386},{"id":385},"使用场景",[387],{"type":26,"value":385},{"type":20,"tag":28,"props":389,"children":390},{},[391],{"type":26,"value":392},"导出业务数据、生成报表、与 Excel 用户协作。",{"type":20,"tag":34,"props":394,"children":395},{"id":57},[396],{"type":26,"value":57},{"type":20,"tag":61,"props":398,"children":400},{"className":63,"code":399,"language":65,"meta":7,"style":7},"[{\"id\":1,\"name\":\"a\"},{\"id\":2,\"name\":\"b\"}]\n",[401],{"type":20,"tag":68,"props":402,"children":403},{"__ignoreMap":7},[404],{"type":20,"tag":72,"props":405,"children":406},{"class":74,"line":75},[407,412,416,421,425,430,434,438,442,447,451,455,460,464,468,472,477],{"type":20,"tag":72,"props":408,"children":409},{"style":79},[410],{"type":26,"value":411},"[{",{"type":20,"tag":72,"props":413,"children":414},{"style":85},[415],{"type":26,"value":88},{"type":20,"tag":72,"props":417,"children":418},{"style":79},[419],{"type":26,"value":420},":",{"type":20,"tag":72,"props":422,"children":423},{"style":85},[424],{"type":26,"value":98},{"type":20,"tag":72,"props":426,"children":427},{"style":79},[428],{"type":26,"value":429},",",{"type":20,"tag":72,"props":431,"children":432},{"style":85},[433],{"type":26,"value":108},{"type":20,"tag":72,"props":435,"children":436},{"style":79},[437],{"type":26,"value":420},{"type":20,"tag":72,"props":439,"children":440},{"style":115},[441],{"type":26,"value":137},{"type":20,"tag":72,"props":443,"children":444},{"style":79},[445],{"type":26,"value":446},"},{",{"type":20,"tag":72,"props":448,"children":449},{"style":85},[450],{"type":26,"value":88},{"type":20,"tag":72,"props":452,"children":453},{"style":79},[454],{"type":26,"value":420},{"type":20,"tag":72,"props":456,"children":457},{"style":85},[458],{"type":26,"value":459},"2",{"type":20,"tag":72,"props":461,"children":462},{"style":79},[463],{"type":26,"value":429},{"type":20,"tag":72,"props":465,"children":466},{"style":85},[467],{"type":26,"value":108},{"type":20,"tag":72,"props":469,"children":470},{"style":79},[471],{"type":26,"value":420},{"type":20,"tag":72,"props":473,"children":474},{"style":115},[475],{"type":26,"value":476},"\"b\"",{"type":20,"tag":72,"props":478,"children":479},{"style":79},[480],{"type":26,"value":481},"}]\n",{"type":20,"tag":34,"props":483,"children":484},{"id":145},[485],{"type":26,"value":145},{"type":20,"tag":149,"props":487,"children":488},{},[489,497],{"type":20,"tag":153,"props":490,"children":491},{},[492],{"type":20,"tag":157,"props":493,"children":495},{"href":494},"/convert/csv",[496],{"type":26,"value":494},{"type":20,"tag":153,"props":498,"children":499},{},[500],{"type":20,"tag":157,"props":501,"children":503},{"href":502},"/flatten",[504],{"type":26,"value":502},{"type":20,"tag":34,"props":506,"children":507},{"id":172},[508],{"type":26,"value":172},{"type":20,"tag":28,"props":510,"children":511},{},[512],{"type":26,"value":513},"将 JSON 数据导出为 Excel xlsx 文件，用于数据分析与报表。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":181,"props":515,"children":516},{},[517],{"type":26,"value":185},{"title":7,"searchDepth":187,"depth":187,"links":519},[520,521,522,523,524],{"id":375,"depth":187,"text":375},{"id":385,"depth":187,"text":385},{"id":57,"depth":187,"text":57},{"id":145,"depth":187,"text":145},{"id":172,"depth":187,"text":172},"content:blog:json-to-excel.md","blog/json-to-excel.md","blog/json-to-excel",{"_path":529,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":530,"description":531,"date":10,"category":11,"keywords":532,"body":536,"_type":194,"_id":667,"_source":196,"_file":668,"_stem":669,"_extension":199},"/blog/json-to-go-struct","JSON 转 Go struct 教程","根据 JSON 生成 Go 结构体，含 json tag，用于 Go 后端快速建模。",[533,534,535],"json转go","json to golang","go struct",{"type":17,"children":537,"toc":660},[538,543,548,552,557,563,576,580,626,630,647,651,656],{"type":20,"tag":21,"props":539,"children":541},{"id":540},"json-转-go-struct-教程",[542],{"type":26,"value":530},{"type":20,"tag":28,"props":544,"children":545},{},[546],{"type":26,"value":547},"根据 JSON 生成 Go 结构体定义，自动添加 json tag，用于 Go 后端反序列化建模。",{"type":20,"tag":34,"props":549,"children":550},{"id":36},[551],{"type":26,"value":36},{"type":20,"tag":28,"props":553,"children":554},{},[555],{"type":26,"value":556},"string→string、number→int/float64、boolean→bool、array→slice、object→嵌套 struct。",{"type":20,"tag":34,"props":558,"children":560},{"id":559},"tag-生成",[561],{"type":26,"value":562},"tag 生成",{"type":20,"tag":28,"props":564,"children":565},{},[566,568,574],{"type":26,"value":567},"默认生成 ",{"type":20,"tag":68,"props":569,"children":571},{"className":570},[],[572],{"type":26,"value":573},"json:\"key\"",{"type":26,"value":575}," tag，可选 omitempty。",{"type":20,"tag":34,"props":577,"children":578},{"id":57},[579],{"type":26,"value":57},{"type":20,"tag":61,"props":581,"children":583},{"className":63,"code":582,"language":65,"meta":7,"style":7},"{\"id\": 1, \"name\": \"x\"}\n",[584],{"type":20,"tag":68,"props":585,"children":586},{"__ignoreMap":7},[587],{"type":20,"tag":72,"props":588,"children":589},{"class":74,"line":75},[590,594,598,602,606,610,614,618,622],{"type":20,"tag":72,"props":591,"children":592},{"style":79},[593],{"type":26,"value":82},{"type":20,"tag":72,"props":595,"children":596},{"style":85},[597],{"type":26,"value":88},{"type":20,"tag":72,"props":599,"children":600},{"style":79},[601],{"type":26,"value":93},{"type":20,"tag":72,"props":603,"children":604},{"style":85},[605],{"type":26,"value":98},{"type":20,"tag":72,"props":607,"children":608},{"style":79},[609],{"type":26,"value":103},{"type":20,"tag":72,"props":611,"children":612},{"style":85},[613],{"type":26,"value":108},{"type":20,"tag":72,"props":615,"children":616},{"style":79},[617],{"type":26,"value":93},{"type":20,"tag":72,"props":619,"children":620},{"style":115},[621],{"type":26,"value":118},{"type":20,"tag":72,"props":623,"children":624},{"style":79},[625],{"type":26,"value":308},{"type":20,"tag":34,"props":627,"children":628},{"id":145},[629],{"type":26,"value":145},{"type":20,"tag":149,"props":631,"children":632},{},[633,640],{"type":20,"tag":153,"props":634,"children":635},{},[636],{"type":20,"tag":157,"props":637,"children":638},{"href":159},[639],{"type":26,"value":159},{"type":20,"tag":153,"props":641,"children":642},{},[643],{"type":20,"tag":157,"props":644,"children":645},{"href":167},[646],{"type":26,"value":167},{"type":20,"tag":34,"props":648,"children":649},{"id":172},[650],{"type":26,"value":172},{"type":20,"tag":28,"props":652,"children":653},{},[654],{"type":26,"value":655},"根据 JSON 生成 Go 结构体，含 json tag，用于 Go 后端快速建模。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":181,"props":657,"children":658},{},[659],{"type":26,"value":185},{"title":7,"searchDepth":187,"depth":187,"links":661},[662,663,664,665,666],{"id":36,"depth":187,"text":36},{"id":559,"depth":187,"text":562},{"id":57,"depth":187,"text":57},{"id":145,"depth":187,"text":145},{"id":172,"depth":187,"text":172},"content:blog:json-to-go-struct.md","blog/json-to-go-struct.md","blog/json-to-go-struct",{"_path":671,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":672,"description":673,"date":10,"category":11,"keywords":674,"body":678,"_type":194,"_id":798,"_source":196,"_file":799,"_stem":800,"_extension":199},"/blog/json-to-graphql","JSON 转 GraphQL 教程","根据 JSON 结构生成 GraphQL type 定义，用于 GraphQL 服务建模。",[675,676,677],"json转graphql","graphql type","graphql",{"type":17,"children":679,"toc":791},[680,685,690,694,699,703,708,712,757,761,778,782,787],{"type":20,"tag":21,"props":681,"children":683},{"id":682},"json-转-graphql-教程",[684],{"type":26,"value":672},{"type":20,"tag":28,"props":686,"children":687},{},[688],{"type":26,"value":689},"根据 JSON 结构生成 GraphQL type 定义，用于 GraphQL 服务的 schema 建模。",{"type":20,"tag":34,"props":691,"children":692},{"id":36},[693],{"type":26,"value":36},{"type":20,"tag":28,"props":695,"children":696},{},[697],{"type":26,"value":698},"string→String、number→Int/Float、boolean→Boolean、array→列表类型、object→嵌套 type。",{"type":20,"tag":34,"props":700,"children":701},{"id":385},[702],{"type":26,"value":385},{"type":20,"tag":28,"props":704,"children":705},{},[706],{"type":26,"value":707},"快速为 GraphQL 服务生成 type 定义，减少手写。",{"type":20,"tag":34,"props":709,"children":710},{"id":57},[711],{"type":26,"value":57},{"type":20,"tag":61,"props":713,"children":714},{"className":63,"code":582,"language":65,"meta":7,"style":7},[715],{"type":20,"tag":68,"props":716,"children":717},{"__ignoreMap":7},[718],{"type":20,"tag":72,"props":719,"children":720},{"class":74,"line":75},[721,725,729,733,737,741,745,749,753],{"type":20,"tag":72,"props":722,"children":723},{"style":79},[724],{"type":26,"value":82},{"type":20,"tag":72,"props":726,"children":727},{"style":85},[728],{"type":26,"value":88},{"type":20,"tag":72,"props":730,"children":731},{"style":79},[732],{"type":26,"value":93},{"type":20,"tag":72,"props":734,"children":735},{"style":85},[736],{"type":26,"value":98},{"type":20,"tag":72,"props":738,"children":739},{"style":79},[740],{"type":26,"value":103},{"type":20,"tag":72,"props":742,"children":743},{"style":85},[744],{"type":26,"value":108},{"type":20,"tag":72,"props":746,"children":747},{"style":79},[748],{"type":26,"value":93},{"type":20,"tag":72,"props":750,"children":751},{"style":115},[752],{"type":26,"value":118},{"type":20,"tag":72,"props":754,"children":755},{"style":79},[756],{"type":26,"value":308},{"type":20,"tag":34,"props":758,"children":759},{"id":145},[760],{"type":26,"value":145},{"type":20,"tag":149,"props":762,"children":763},{},[764,771],{"type":20,"tag":153,"props":765,"children":766},{},[767],{"type":20,"tag":157,"props":768,"children":769},{"href":159},[770],{"type":26,"value":159},{"type":20,"tag":153,"props":772,"children":773},{},[774],{"type":20,"tag":157,"props":775,"children":776},{"href":167},[777],{"type":26,"value":167},{"type":20,"tag":34,"props":779,"children":780},{"id":172},[781],{"type":26,"value":172},{"type":20,"tag":28,"props":783,"children":784},{},[785],{"type":26,"value":786},"根据 JSON 结构生成 GraphQL type 定义，用于 GraphQL 服务建模。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":181,"props":788,"children":789},{},[790],{"type":26,"value":185},{"title":7,"searchDepth":187,"depth":187,"links":792},[793,794,795,796,797],{"id":36,"depth":187,"text":36},{"id":385,"depth":187,"text":385},{"id":57,"depth":187,"text":57},{"id":145,"depth":187,"text":145},{"id":172,"depth":187,"text":172},"content:blog:json-to-graphql.md","blog/json-to-graphql.md","blog/json-to-graphql",1787305467563]