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