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