[{"data":1,"prerenderedAt":797},["ShallowReactive",2],{"post-/blog/json-rpc":3,"related-/blog/json-rpc":217},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"keywords":12,"body":16,"_type":211,"_id":212,"_source":213,"_file":214,"_stem":215,"_extension":216},"/blog/json-rpc","blog",false,"","JSON-RPC 协议详解","JSON-RPC 是基于 JSON 的远程过程调用协议，轻量、无状态，支持 HTTP 与 WebSocket。","2026-08-19","进阶",[13,14,15],"json-rpc","json rpc","远程调用",{"type":17,"children":18,"toc":203},"root",[19,27,33,39,44,49,54,59,160,165,187,192,197],{"type":20,"tag":21,"props":22,"children":24},"element","h1",{"id":23},"json-rpc-协议详解",[25],{"type":26,"value":8},"text",{"type":20,"tag":28,"props":29,"children":30},"p",{},[31],{"type":26,"value":32},"JSON-RPC 是一种基于 JSON 的轻量级远程过程调用协议，用 JSON 描述请求与响应。",{"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},"请求含 jsonrpc、method、params、id；响应含 result 或 error 与对应 id。",{"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},"区块链节点交互、内部微服务通信、WebSocket 接口。",{"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","{\"jsonrpc\":\"2.0\",\"method\":\"getUser\",\"params\":[1],\"id\":1}\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,99,104,109,113,118,122,127,132,137,142,147,151,155],{"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},"\"jsonrpc\"",{"type":20,"tag":71,"props":89,"children":90},{"style":78},[91],{"type":26,"value":92},":",{"type":20,"tag":71,"props":94,"children":96},{"style":95},"--shiki-default:#9ECBFF",[97],{"type":26,"value":98},"\"2.0\"",{"type":20,"tag":71,"props":100,"children":101},{"style":78},[102],{"type":26,"value":103},",",{"type":20,"tag":71,"props":105,"children":106},{"style":84},[107],{"type":26,"value":108},"\"method\"",{"type":20,"tag":71,"props":110,"children":111},{"style":78},[112],{"type":26,"value":92},{"type":20,"tag":71,"props":114,"children":115},{"style":95},[116],{"type":26,"value":117},"\"getUser\"",{"type":20,"tag":71,"props":119,"children":120},{"style":78},[121],{"type":26,"value":103},{"type":20,"tag":71,"props":123,"children":124},{"style":84},[125],{"type":26,"value":126},"\"params\"",{"type":20,"tag":71,"props":128,"children":129},{"style":78},[130],{"type":26,"value":131},":[",{"type":20,"tag":71,"props":133,"children":134},{"style":84},[135],{"type":26,"value":136},"1",{"type":20,"tag":71,"props":138,"children":139},{"style":78},[140],{"type":26,"value":141},"],",{"type":20,"tag":71,"props":143,"children":144},{"style":84},[145],{"type":26,"value":146},"\"id\"",{"type":20,"tag":71,"props":148,"children":149},{"style":78},[150],{"type":26,"value":92},{"type":20,"tag":71,"props":152,"children":153},{"style":84},[154],{"type":26,"value":136},{"type":20,"tag":71,"props":156,"children":157},{"style":78},[158],{"type":26,"value":159},"}\n",{"type":20,"tag":34,"props":161,"children":163},{"id":162},"推荐在线工具",[164],{"type":26,"value":162},{"type":20,"tag":166,"props":167,"children":168},"ul",{},[169,179],{"type":20,"tag":170,"props":171,"children":172},"li",{},[173],{"type":20,"tag":174,"props":175,"children":177},"a",{"href":176},"/format",[178],{"type":26,"value":176},{"type":20,"tag":170,"props":180,"children":181},{},[182],{"type":20,"tag":174,"props":183,"children":185},{"href":184},"/validate",[186],{"type":26,"value":184},{"type":20,"tag":34,"props":188,"children":190},{"id":189},"小结",[191],{"type":26,"value":189},{"type":20,"tag":28,"props":193,"children":194},{},[195],{"type":26,"value":196},"JSON-RPC 是基于 JSON 的远程过程调用协议，轻量、无状态，支持 HTTP 与 WebSocket。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":198,"props":199,"children":200},"style",{},[201],{"type":26,"value":202},"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":204,"depth":204,"links":205},2,[206,207,208,209,210],{"id":36,"depth":204,"text":36},{"id":46,"depth":204,"text":46},{"id":56,"depth":204,"text":56},{"id":162,"depth":204,"text":162},{"id":189,"depth":204,"text":189},"markdown","content:blog:json-rpc.md","content","blog/json-rpc.md","blog/json-rpc","md",[218,396,517,675],{"_path":219,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":220,"description":221,"date":10,"category":11,"keywords":222,"body":226,"_type":211,"_id":393,"_source":213,"_file":394,"_stem":395,"_extension":216},"/blog/json-api-spec","JSON:API 规范指南","JSON:API 是 RESTful API 的数据响应规范，统一资源、关系、分页、错误格式。",[223,224,225],"json:api","json api规范","restful",{"type":17,"children":227,"toc":386},[228,233,238,243,248,253,258,262,352,356,373,377,382],{"type":20,"tag":21,"props":229,"children":231},{"id":230},"jsonapi-规范指南",[232],{"type":26,"value":220},{"type":20,"tag":28,"props":234,"children":235},{},[236],{"type":26,"value":237},"JSON:API 是一套构建 RESTful API 数据响应的规范，统一了资源对象、关系、分页与错误的 JSON 结构。",{"type":20,"tag":34,"props":239,"children":241},{"id":240},"核心约定",[242],{"type":26,"value":240},{"type":20,"tag":28,"props":244,"children":245},{},[246],{"type":26,"value":247},"data 包含资源数组或单对象，relationships 描述关联，included 包含关联资源，meta 存元信息。",{"type":20,"tag":34,"props":249,"children":251},{"id":250},"优势",[252],{"type":26,"value":250},{"type":20,"tag":28,"props":254,"children":255},{},[256],{"type":26,"value":257},"统一格式减少约定成本，客户端可通用化处理。",{"type":20,"tag":34,"props":259,"children":260},{"id":56},[261],{"type":26,"value":56},{"type":20,"tag":60,"props":263,"children":265},{"className":62,"code":264,"language":64,"meta":7,"style":7},"{\"data\": [{\"type\": \"user\", \"id\": \"1\", \"attributes\": {\"name\": \"x\"}}]}\n",[266],{"type":20,"tag":67,"props":267,"children":268},{"__ignoreMap":7},[269],{"type":20,"tag":71,"props":270,"children":271},{"class":73,"line":74},[272,276,281,286,291,296,301,306,310,314,319,323,328,333,338,342,347],{"type":20,"tag":71,"props":273,"children":274},{"style":78},[275],{"type":26,"value":81},{"type":20,"tag":71,"props":277,"children":278},{"style":84},[279],{"type":26,"value":280},"\"data\"",{"type":20,"tag":71,"props":282,"children":283},{"style":78},[284],{"type":26,"value":285},": [{",{"type":20,"tag":71,"props":287,"children":288},{"style":84},[289],{"type":26,"value":290},"\"type\"",{"type":20,"tag":71,"props":292,"children":293},{"style":78},[294],{"type":26,"value":295},": ",{"type":20,"tag":71,"props":297,"children":298},{"style":95},[299],{"type":26,"value":300},"\"user\"",{"type":20,"tag":71,"props":302,"children":303},{"style":78},[304],{"type":26,"value":305},", ",{"type":20,"tag":71,"props":307,"children":308},{"style":84},[309],{"type":26,"value":146},{"type":20,"tag":71,"props":311,"children":312},{"style":78},[313],{"type":26,"value":295},{"type":20,"tag":71,"props":315,"children":316},{"style":95},[317],{"type":26,"value":318},"\"1\"",{"type":20,"tag":71,"props":320,"children":321},{"style":78},[322],{"type":26,"value":305},{"type":20,"tag":71,"props":324,"children":325},{"style":84},[326],{"type":26,"value":327},"\"attributes\"",{"type":20,"tag":71,"props":329,"children":330},{"style":78},[331],{"type":26,"value":332},": {",{"type":20,"tag":71,"props":334,"children":335},{"style":84},[336],{"type":26,"value":337},"\"name\"",{"type":20,"tag":71,"props":339,"children":340},{"style":78},[341],{"type":26,"value":295},{"type":20,"tag":71,"props":343,"children":344},{"style":95},[345],{"type":26,"value":346},"\"x\"",{"type":20,"tag":71,"props":348,"children":349},{"style":78},[350],{"type":26,"value":351},"}}]}\n",{"type":20,"tag":34,"props":353,"children":354},{"id":162},[355],{"type":26,"value":162},{"type":20,"tag":166,"props":357,"children":358},{},[359,366],{"type":20,"tag":170,"props":360,"children":361},{},[362],{"type":20,"tag":174,"props":363,"children":364},{"href":176},[365],{"type":26,"value":176},{"type":20,"tag":170,"props":367,"children":368},{},[369],{"type":20,"tag":174,"props":370,"children":371},{"href":184},[372],{"type":26,"value":184},{"type":20,"tag":34,"props":374,"children":375},{"id":189},[376],{"type":26,"value":189},{"type":20,"tag":28,"props":378,"children":379},{},[380],{"type":26,"value":381},"JSON:API 是 RESTful API 的数据响应规范，统一资源、关系、分页、错误格式。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":198,"props":383,"children":384},{},[385],{"type":26,"value":202},{"title":7,"searchDepth":204,"depth":204,"links":387},[388,389,390,391,392],{"id":240,"depth":204,"text":240},{"id":250,"depth":204,"text":250},{"id":56,"depth":204,"text":56},{"id":162,"depth":204,"text":162},{"id":189,"depth":204,"text":189},"content:blog:json-api-spec.md","blog/json-api-spec.md","blog/json-api-spec",{"_path":397,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":398,"description":399,"date":10,"category":11,"keywords":400,"body":404,"_type":211,"_id":514,"_source":213,"_file":515,"_stem":516,"_extension":216},"/blog/json-deserialization","JSON 反序列化注意事项","JSON 反序列化将字符串转为对象，需注意类型丢失、精度、安全与错误处理。",[401,402,403],"json反序列化","json parse","反序列化",{"type":17,"children":405,"toc":507},[406,411,416,421,426,431,436,440,473,477,494,498,503],{"type":20,"tag":21,"props":407,"children":409},{"id":408},"json-反序列化注意事项",[410],{"type":26,"value":398},{"type":20,"tag":28,"props":412,"children":413},{},[414],{"type":26,"value":415},"JSON 反序列化将 JSON 字符串解析为内存对象，过程中需注意类型、精度与安全。",{"type":20,"tag":34,"props":417,"children":419},{"id":418},"常见问题",[420],{"type":26,"value":418},{"type":20,"tag":28,"props":422,"children":423},{},[424],{"type":26,"value":425},"大整数精度丢失（JS Number 限制）、日期需手动转换、类型信息丢失、非法 JSON 抛错。",{"type":20,"tag":34,"props":427,"children":429},{"id":428},"安全",[430],{"type":26,"value":428},{"type":20,"tag":28,"props":432,"children":433},{},[434],{"type":26,"value":435},"避免 eval 解析（注入风险），使用 JSON.parse；注意原型链污染。",{"type":20,"tag":34,"props":437,"children":438},{"id":56},[439],{"type":26,"value":56},{"type":20,"tag":60,"props":441,"children":443},{"className":62,"code":442,"language":64,"meta":7,"style":7},"JSON.parse('{\"a\":1}')\n",[444],{"type":20,"tag":67,"props":445,"children":446},{"__ignoreMap":7},[447],{"type":20,"tag":71,"props":448,"children":449},{"class":73,"line":74},[450,455,460,464,468],{"type":20,"tag":71,"props":451,"children":452},{"style":78},[453],{"type":26,"value":454},"JSON.parse('{",{"type":20,"tag":71,"props":456,"children":457},{"style":84},[458],{"type":26,"value":459},"\"a\"",{"type":20,"tag":71,"props":461,"children":462},{"style":78},[463],{"type":26,"value":92},{"type":20,"tag":71,"props":465,"children":466},{"style":84},[467],{"type":26,"value":136},{"type":20,"tag":71,"props":469,"children":470},{"style":78},[471],{"type":26,"value":472},"}')\n",{"type":20,"tag":34,"props":474,"children":475},{"id":162},[476],{"type":26,"value":162},{"type":20,"tag":166,"props":478,"children":479},{},[480,487],{"type":20,"tag":170,"props":481,"children":482},{},[483],{"type":20,"tag":174,"props":484,"children":485},{"href":184},[486],{"type":26,"value":184},{"type":20,"tag":170,"props":488,"children":489},{},[490],{"type":20,"tag":174,"props":491,"children":492},{"href":176},[493],{"type":26,"value":176},{"type":20,"tag":34,"props":495,"children":496},{"id":189},[497],{"type":26,"value":189},{"type":20,"tag":28,"props":499,"children":500},{},[501],{"type":26,"value":502},"JSON 反序列化将字符串转为对象，需注意类型丢失、精度、安全与错误处理。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":198,"props":504,"children":505},{},[506],{"type":26,"value":202},{"title":7,"searchDepth":204,"depth":204,"links":508},[509,510,511,512,513],{"id":418,"depth":204,"text":418},{"id":428,"depth":204,"text":428},{"id":56,"depth":204,"text":56},{"id":162,"depth":204,"text":162},{"id":189,"depth":204,"text":189},"content:blog:json-deserialization.md","blog/json-deserialization.md","blog/json-deserialization",{"_path":518,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":519,"description":520,"date":10,"category":11,"keywords":521,"body":525,"_type":211,"_id":672,"_source":213,"_file":673,"_stem":674,"_extension":216},"/blog/json-patch","JSON Patch 操作详解","JSON Patch (RFC 6902) 用一组操作描述 JSON 变更，支持 add/remove/replace/move/copy/test。",[522,523,524],"json patch","rfc 6902","json变更",{"type":17,"children":526,"toc":665},[527,532,537,542,547,551,556,560,630,634,652,656,661],{"type":20,"tag":21,"props":528,"children":530},{"id":529},"json-patch-操作详解",[531],{"type":26,"value":519},{"type":20,"tag":28,"props":533,"children":534},{},[535],{"type":26,"value":536},"JSON Patch 是 RFC 6902 定义的用操作数组描述 JSON 变更的格式，常用于增量更新与协同。",{"type":20,"tag":34,"props":538,"children":540},{"id":539},"操作类型",[541],{"type":26,"value":539},{"type":20,"tag":28,"props":543,"children":544},{},[545],{"type":26,"value":546},"add 添加、remove 删除、replace 替换、move 移动、copy 复制、test 测试。",{"type":20,"tag":34,"props":548,"children":549},{"id":46},[550],{"type":26,"value":46},{"type":20,"tag":28,"props":552,"children":553},{},[554],{"type":26,"value":555},"API 增量更新、协同编辑、版本差异表达。",{"type":20,"tag":34,"props":557,"children":558},{"id":56},[559],{"type":26,"value":56},{"type":20,"tag":60,"props":561,"children":563},{"className":62,"code":562,"language":64,"meta":7,"style":7},"[{\"op\":\"replace\",\"path\":\"/name\",\"value\":\"新值\"}]\n",[564],{"type":20,"tag":67,"props":565,"children":566},{"__ignoreMap":7},[567],{"type":20,"tag":71,"props":568,"children":569},{"class":73,"line":74},[570,575,580,584,589,593,598,602,607,611,616,620,625],{"type":20,"tag":71,"props":571,"children":572},{"style":78},[573],{"type":26,"value":574},"[{",{"type":20,"tag":71,"props":576,"children":577},{"style":84},[578],{"type":26,"value":579},"\"op\"",{"type":20,"tag":71,"props":581,"children":582},{"style":78},[583],{"type":26,"value":92},{"type":20,"tag":71,"props":585,"children":586},{"style":95},[587],{"type":26,"value":588},"\"replace\"",{"type":20,"tag":71,"props":590,"children":591},{"style":78},[592],{"type":26,"value":103},{"type":20,"tag":71,"props":594,"children":595},{"style":84},[596],{"type":26,"value":597},"\"path\"",{"type":20,"tag":71,"props":599,"children":600},{"style":78},[601],{"type":26,"value":92},{"type":20,"tag":71,"props":603,"children":604},{"style":95},[605],{"type":26,"value":606},"\"/name\"",{"type":20,"tag":71,"props":608,"children":609},{"style":78},[610],{"type":26,"value":103},{"type":20,"tag":71,"props":612,"children":613},{"style":84},[614],{"type":26,"value":615},"\"value\"",{"type":20,"tag":71,"props":617,"children":618},{"style":78},[619],{"type":26,"value":92},{"type":20,"tag":71,"props":621,"children":622},{"style":95},[623],{"type":26,"value":624},"\"新值\"",{"type":20,"tag":71,"props":626,"children":627},{"style":78},[628],{"type":26,"value":629},"}]\n",{"type":20,"tag":34,"props":631,"children":632},{"id":162},[633],{"type":26,"value":162},{"type":20,"tag":166,"props":635,"children":636},{},[637,645],{"type":20,"tag":170,"props":638,"children":639},{},[640],{"type":20,"tag":174,"props":641,"children":643},{"href":642},"/diff",[644],{"type":26,"value":642},{"type":20,"tag":170,"props":646,"children":647},{},[648],{"type":20,"tag":174,"props":649,"children":650},{"href":176},[651],{"type":26,"value":176},{"type":20,"tag":34,"props":653,"children":654},{"id":189},[655],{"type":26,"value":189},{"type":20,"tag":28,"props":657,"children":658},{},[659],{"type":26,"value":660},"JSON Patch (RFC 6902) 用一组操作描述 JSON 变更，支持 add/remove/replace/move/copy/test。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":198,"props":662,"children":663},{},[664],{"type":26,"value":202},{"title":7,"searchDepth":204,"depth":204,"links":666},[667,668,669,670,671],{"id":539,"depth":204,"text":539},{"id":46,"depth":204,"text":46},{"id":56,"depth":204,"text":56},{"id":162,"depth":204,"text":162},{"id":189,"depth":204,"text":189},"content:blog:json-patch.md","blog/json-patch.md","blog/json-patch",{"_path":676,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":677,"description":678,"date":10,"category":11,"keywords":679,"body":683,"_type":211,"_id":794,"_source":213,"_file":795,"_stem":796,"_extension":216},"/blog/json-performance","JSON 性能优化技巧","大 JSON 解析与传输优化：压缩、流式解析、字段裁剪、二进制替代方案。",[680,681,682],"json性能","json优化","大json",{"type":17,"children":684,"toc":787},[685,690,695,700,705,710,715,719,751,755,774,778,783],{"type":20,"tag":21,"props":686,"children":688},{"id":687},"json-性能优化技巧",[689],{"type":26,"value":677},{"type":20,"tag":28,"props":691,"children":692},{},[693],{"type":26,"value":694},"大 JSON 的解析与传输可能成为性能瓶颈，可通过多种手段优化。",{"type":20,"tag":34,"props":696,"children":698},{"id":697},"优化手段",[699],{"type":26,"value":697},{"type":20,"tag":28,"props":701,"children":702},{},[703],{"type":26,"value":704},"传输前 minify、gzip 压缩、流式解析（SAX）、按需裁剪字段、考虑 Protobuf/MessagePack。",{"type":20,"tag":34,"props":706,"children":708},{"id":707},"解析优化",[709],{"type":26,"value":707},{"type":20,"tag":28,"props":711,"children":712},{},[713],{"type":26,"value":714},"选用高性能库（如 simdjson）、Web Worker 避免阻塞主线程。",{"type":20,"tag":34,"props":716,"children":717},{"id":56},[718],{"type":26,"value":56},{"type":20,"tag":60,"props":720,"children":722},{"className":62,"code":721,"language":64,"meta":7,"style":7},"{\"big\": \"data...\"}\n",[723],{"type":20,"tag":67,"props":724,"children":725},{"__ignoreMap":7},[726],{"type":20,"tag":71,"props":727,"children":728},{"class":73,"line":74},[729,733,738,742,747],{"type":20,"tag":71,"props":730,"children":731},{"style":78},[732],{"type":26,"value":81},{"type":20,"tag":71,"props":734,"children":735},{"style":84},[736],{"type":26,"value":737},"\"big\"",{"type":20,"tag":71,"props":739,"children":740},{"style":78},[741],{"type":26,"value":295},{"type":20,"tag":71,"props":743,"children":744},{"style":95},[745],{"type":26,"value":746},"\"data...\"",{"type":20,"tag":71,"props":748,"children":749},{"style":78},[750],{"type":26,"value":159},{"type":20,"tag":34,"props":752,"children":753},{"id":162},[754],{"type":26,"value":162},{"type":20,"tag":166,"props":756,"children":757},{},[758,766],{"type":20,"tag":170,"props":759,"children":760},{},[761],{"type":20,"tag":174,"props":762,"children":764},{"href":763},"/minify",[765],{"type":26,"value":763},{"type":20,"tag":170,"props":767,"children":768},{},[769],{"type":20,"tag":174,"props":770,"children":772},{"href":771},"/visualize",[773],{"type":26,"value":771},{"type":20,"tag":34,"props":775,"children":776},{"id":189},[777],{"type":26,"value":189},{"type":20,"tag":28,"props":779,"children":780},{},[781],{"type":26,"value":782},"大 JSON 解析与传输优化：压缩、流式解析、字段裁剪、二进制替代方案。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":198,"props":784,"children":785},{},[786],{"type":26,"value":202},{"title":7,"searchDepth":204,"depth":204,"links":788},[789,790,791,792,793],{"id":697,"depth":204,"text":697},{"id":707,"depth":204,"text":707},{"id":56,"depth":204,"text":56},{"id":162,"depth":204,"text":162},{"id":189,"depth":204,"text":189},"content:blog:json-performance.md","blog/json-performance.md","blog/json-performance",1787305467112]