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