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