[{"data":1,"prerenderedAt":802},["ShallowReactive",2],{"post-/blog/json-caching":3,"related-/blog/json-caching":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-caching","blog",false,"","JSON 缓存策略","JSON 响应可缓存于 CDN、Redis、本地，本文介绍缓存键设计与失效策略。","2026-08-19","场景",[13,14,15],"json缓存","api缓存","redis json",{"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-缓存策略",[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],{"type":26,"value":43},"CDN 缓存静态 JSON、Redis 缓存热点接口、浏览器缓存带 ETag。",{"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},"TTL 过期、版本号键、主动清除，注意一致性。",{"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","{\"key\": \"user:1:profile\", \"ttl\": 3600}\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],{"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},"\"key\"",{"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},"\"user:1:profile\"",{"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},"\"ttl\"",{"type":20,"tag":71,"props":110,"children":111},{"style":78},[112],{"type":26,"value":92},{"type":20,"tag":71,"props":114,"children":115},{"style":84},[116],{"type":26,"value":117},"3600",{"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},"/minify",[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 响应可缓存于 CDN、Redis、本地，本文介绍缓存键设计与失效策略。 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-caching.md","content","blog/json-caching.md","blog/json-caching","md",[181,333,498,636],{"_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":330,"_source":176,"_file":331,"_stem":332,"_extension":179},"/blog/json-as-config","JSON 作为配置文件","JSON 常用作配置文件，但不支持注释，可考虑 JSON5 或 JSONC 替代。",[186,187,188],"json配置","json config","jsonc",{"type":17,"children":190,"toc":323},[191,196,201,206,211,216,221,225,288,292,310,314,319],{"type":20,"tag":21,"props":192,"children":194},{"id":193},"json-作为配置文件",[195],{"type":26,"value":183},{"type":20,"tag":28,"props":197,"children":198},{},[199],{"type":26,"value":200},"JSON 常用作配置文件（如 tsconfig、package.json），但不支持注释，编辑不便。",{"type":20,"tag":34,"props":202,"children":204},{"id":203},"优缺点",[205],{"type":26,"value":203},{"type":20,"tag":28,"props":207,"children":208},{},[209],{"type":26,"value":210},"优点：标准、解析快、跨语言；缺点：无注释、无多行字符串、尾逗号非法。",{"type":20,"tag":34,"props":212,"children":214},{"id":213},"替代方案",[215],{"type":26,"value":213},{"type":20,"tag":28,"props":217,"children":218},{},[219],{"type":26,"value":220},"JSON5、JSONC（带注释）、YAML、TOML 更适合人工编辑的配置。",{"type":20,"tag":34,"props":222,"children":223},{"id":56},[224],{"type":26,"value":56},{"type":20,"tag":60,"props":226,"children":228},{"className":62,"code":227,"language":64,"meta":7,"style":7},"{\n  \"compilerOptions\": {\n    \"target\": \"es2020\"\n  }\n}\n",[229],{"type":20,"tag":67,"props":230,"children":231},{"__ignoreMap":7},[232,240,253,271,280],{"type":20,"tag":71,"props":233,"children":234},{"class":73,"line":74},[235],{"type":20,"tag":71,"props":236,"children":237},{"style":78},[238],{"type":26,"value":239},"{\n",{"type":20,"tag":71,"props":241,"children":242},{"class":73,"line":167},[243,248],{"type":20,"tag":71,"props":244,"children":245},{"style":84},[246],{"type":26,"value":247},"  \"compilerOptions\"",{"type":20,"tag":71,"props":249,"children":250},{"style":78},[251],{"type":26,"value":252},": {\n",{"type":20,"tag":71,"props":254,"children":256},{"class":73,"line":255},3,[257,262,266],{"type":20,"tag":71,"props":258,"children":259},{"style":84},[260],{"type":26,"value":261},"    \"target\"",{"type":20,"tag":71,"props":263,"children":264},{"style":78},[265],{"type":26,"value":92},{"type":20,"tag":71,"props":267,"children":268},{"style":95},[269],{"type":26,"value":270},"\"es2020\"\n",{"type":20,"tag":71,"props":272,"children":274},{"class":73,"line":273},4,[275],{"type":20,"tag":71,"props":276,"children":277},{"style":78},[278],{"type":26,"value":279},"  }\n",{"type":20,"tag":71,"props":281,"children":283},{"class":73,"line":282},5,[284],{"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":147},[301],{"type":26,"value":147},{"type":20,"tag":133,"props":303,"children":304},{},[305],{"type":20,"tag":137,"props":306,"children":308},{"href":307},"/validate",[309],{"type":26,"value":307},{"type":20,"tag":34,"props":311,"children":312},{"id":152},[313],{"type":26,"value":152},{"type":20,"tag":28,"props":315,"children":316},{},[317],{"type":26,"value":318},"JSON 常用作配置文件，但不支持注释，可考虑 JSON5 或 JSONC 替代。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":161,"props":320,"children":321},{},[322],{"type":26,"value":165},{"title":7,"searchDepth":167,"depth":167,"links":324},[325,326,327,328,329],{"id":203,"depth":167,"text":203},{"id":213,"depth":167,"text":213},{"id":56,"depth":167,"text":56},{"id":125,"depth":167,"text":125},{"id":152,"depth":167,"text":152},"content:blog:json-as-config.md","blog/json-as-config.md","blog/json-as-config",{"_path":334,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":335,"description":336,"date":10,"category":11,"keywords":337,"body":341,"_type":174,"_id":495,"_source":176,"_file":496,"_stem":497,"_extension":179},"/blog/json-form-data","JSON 与表单数据转换","前端表单常需与 JSON 互转，本文介绍序列化、嵌套表单与提交技巧。",[338,339,340],"json表单","form json","表单序列化",{"type":17,"children":342,"toc":488},[343,348,353,358,368,373,378,382,453,457,475,479,484],{"type":20,"tag":21,"props":344,"children":346},{"id":345},"json-与表单数据转换",[347],{"type":26,"value":335},{"type":20,"tag":28,"props":349,"children":350},{},[351],{"type":26,"value":352},"前端表单数据常需转为 JSON 提交 API，或将 JSON 回填表单，需处理嵌套与数组。",{"type":20,"tag":34,"props":354,"children":356},{"id":355},"转换方式",[357],{"type":26,"value":355},{"type":20,"tag":28,"props":359,"children":360},{},[361,363,366],{"type":26,"value":362},"FormData 遍历构建对象、name 用点路径表达嵌套、数组用 ",{"type":20,"tag":71,"props":364,"children":365},{},[],{"type":26,"value":367}," 后缀。",{"type":20,"tag":34,"props":369,"children":371},{"id":370},"库推荐",[372],{"type":26,"value":370},{"type":20,"tag":28,"props":374,"children":375},{},[376],{"type":26,"value":377},"qs、form-serialize、或框架内置（如 Vue v-model）。",{"type":20,"tag":34,"props":379,"children":380},{"id":56},[381],{"type":26,"value":56},{"type":20,"tag":60,"props":383,"children":385},{"className":62,"code":384,"language":64,"meta":7,"style":7},"{\"user\": {\"name\": \"x\", \"tags\": [\"a\", \"b\"]}}\n",[386],{"type":20,"tag":67,"props":387,"children":388},{"__ignoreMap":7},[389],{"type":20,"tag":71,"props":390,"children":391},{"class":73,"line":74},[392,396,401,406,411,415,420,424,429,434,439,443,448],{"type":20,"tag":71,"props":393,"children":394},{"style":78},[395],{"type":26,"value":81},{"type":20,"tag":71,"props":397,"children":398},{"style":84},[399],{"type":26,"value":400},"\"user\"",{"type":20,"tag":71,"props":402,"children":403},{"style":78},[404],{"type":26,"value":405},": {",{"type":20,"tag":71,"props":407,"children":408},{"style":84},[409],{"type":26,"value":410},"\"name\"",{"type":20,"tag":71,"props":412,"children":413},{"style":78},[414],{"type":26,"value":92},{"type":20,"tag":71,"props":416,"children":417},{"style":95},[418],{"type":26,"value":419},"\"x\"",{"type":20,"tag":71,"props":421,"children":422},{"style":78},[423],{"type":26,"value":103},{"type":20,"tag":71,"props":425,"children":426},{"style":84},[427],{"type":26,"value":428},"\"tags\"",{"type":20,"tag":71,"props":430,"children":431},{"style":78},[432],{"type":26,"value":433},": [",{"type":20,"tag":71,"props":435,"children":436},{"style":95},[437],{"type":26,"value":438},"\"a\"",{"type":20,"tag":71,"props":440,"children":441},{"style":78},[442],{"type":26,"value":103},{"type":20,"tag":71,"props":444,"children":445},{"style":95},[446],{"type":26,"value":447},"\"b\"",{"type":20,"tag":71,"props":449,"children":450},{"style":78},[451],{"type":26,"value":452},"]}}\n",{"type":20,"tag":34,"props":454,"children":455},{"id":125},[456],{"type":26,"value":125},{"type":20,"tag":129,"props":458,"children":459},{},[460,468],{"type":20,"tag":133,"props":461,"children":462},{},[463],{"type":20,"tag":137,"props":464,"children":466},{"href":465},"/flatten",[467],{"type":26,"value":465},{"type":20,"tag":133,"props":469,"children":470},{},[471],{"type":20,"tag":137,"props":472,"children":473},{"href":147},[474],{"type":26,"value":147},{"type":20,"tag":34,"props":476,"children":477},{"id":152},[478],{"type":26,"value":152},{"type":20,"tag":28,"props":480,"children":481},{},[482],{"type":26,"value":483},"前端表单常需与 JSON 互转，本文介绍序列化、嵌套表单与提交技巧。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":161,"props":485,"children":486},{},[487],{"type":26,"value":165},{"title":7,"searchDepth":167,"depth":167,"links":489},[490,491,492,493,494],{"id":355,"depth":167,"text":355},{"id":370,"depth":167,"text":370},{"id":56,"depth":167,"text":56},{"id":125,"depth":167,"text":125},{"id":152,"depth":167,"text":152},"content:blog:json-form-data.md","blog/json-form-data.md","blog/json-form-data",{"_path":499,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":500,"description":501,"date":10,"category":11,"keywords":502,"body":506,"_type":174,"_id":633,"_source":176,"_file":634,"_stem":635,"_extension":179},"/blog/json-i18n","JSON 与国际化方案","JSON 是 i18n 资源文件常用格式，按语言分文件，键值映射文案。",[503,504,505],"json i18n","国际化json","多语言json",{"type":17,"children":507,"toc":626},[508,513,518,523,528,533,538,542,592,596,613,617,622],{"type":20,"tag":21,"props":509,"children":511},{"id":510},"json-与国际化方案",[512],{"type":26,"value":500},{"type":20,"tag":28,"props":514,"children":515},{},[516],{"type":26,"value":517},"JSON 是国际化资源文件的常用格式，按语言分文件，键值对映射文案。",{"type":20,"tag":34,"props":519,"children":521},{"id":520},"结构设计",[522],{"type":26,"value":520},{"type":20,"tag":28,"props":524,"children":525},{},[526],{"type":26,"value":527},"按语言分文件（en.json、zh.json），键用点路径或嵌套对象组织命名空间。",{"type":20,"tag":34,"props":529,"children":531},{"id":530},"使用",[532],{"type":26,"value":530},{"type":20,"tag":28,"props":534,"children":535},{},[536],{"type":26,"value":537},"前端 i18n 库加载对应语言 JSON，按键取文案，支持插值与复数。",{"type":20,"tag":34,"props":539,"children":540},{"id":56},[541],{"type":26,"value":56},{"type":20,"tag":60,"props":543,"children":545},{"className":62,"code":544,"language":64,"meta":7,"style":7},"{\"welcome\": \"欢迎\", \"login\": \"登录\"}\n",[546],{"type":20,"tag":67,"props":547,"children":548},{"__ignoreMap":7},[549],{"type":20,"tag":71,"props":550,"children":551},{"class":73,"line":74},[552,556,561,565,570,574,579,583,588],{"type":20,"tag":71,"props":553,"children":554},{"style":78},[555],{"type":26,"value":81},{"type":20,"tag":71,"props":557,"children":558},{"style":84},[559],{"type":26,"value":560},"\"welcome\"",{"type":20,"tag":71,"props":562,"children":563},{"style":78},[564],{"type":26,"value":92},{"type":20,"tag":71,"props":566,"children":567},{"style":95},[568],{"type":26,"value":569},"\"欢迎\"",{"type":20,"tag":71,"props":571,"children":572},{"style":78},[573],{"type":26,"value":103},{"type":20,"tag":71,"props":575,"children":576},{"style":84},[577],{"type":26,"value":578},"\"login\"",{"type":20,"tag":71,"props":580,"children":581},{"style":78},[582],{"type":26,"value":92},{"type":20,"tag":71,"props":584,"children":585},{"style":95},[586],{"type":26,"value":587},"\"登录\"",{"type":20,"tag":71,"props":589,"children":590},{"style":78},[591],{"type":26,"value":122},{"type":20,"tag":34,"props":593,"children":594},{"id":125},[595],{"type":26,"value":125},{"type":20,"tag":129,"props":597,"children":598},{},[599,606],{"type":20,"tag":133,"props":600,"children":601},{},[602],{"type":20,"tag":137,"props":603,"children":604},{"href":147},[605],{"type":26,"value":147},{"type":20,"tag":133,"props":607,"children":608},{},[609],{"type":20,"tag":137,"props":610,"children":611},{"href":307},[612],{"type":26,"value":307},{"type":20,"tag":34,"props":614,"children":615},{"id":152},[616],{"type":26,"value":152},{"type":20,"tag":28,"props":618,"children":619},{},[620],{"type":26,"value":621},"JSON 是 i18n 资源文件常用格式，按语言分文件，键值映射文案。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":161,"props":623,"children":624},{},[625],{"type":26,"value":165},{"title":7,"searchDepth":167,"depth":167,"links":627},[628,629,630,631,632],{"id":520,"depth":167,"text":520},{"id":530,"depth":167,"text":530},{"id":56,"depth":167,"text":56},{"id":125,"depth":167,"text":125},{"id":152,"depth":167,"text":152},"content:blog:json-i18n.md","blog/json-i18n.md","blog/json-i18n",{"_path":637,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":638,"description":639,"date":10,"category":11,"keywords":640,"body":644,"_type":174,"_id":799,"_source":176,"_file":800,"_stem":801,"_extension":179},"/blog/json-in-api","JSON 在 API 中的应用","RESTful 与 GraphQL API 普遍用 JSON 作为请求响应格式，本文介绍最佳实践。",[641,642,643],"json api","restful json","api响应",{"type":17,"children":645,"toc":792},[646,651,656,661,666,671,676,680,758,762,779,783,788],{"type":20,"tag":21,"props":647,"children":649},{"id":648},"json-在-api-中的应用",[650],{"type":26,"value":638},{"type":20,"tag":28,"props":652,"children":653},{},[654],{"type":26,"value":655},"JSON 是当今 Web API 事实标准格式，RESTful 与 GraphQL 均广泛采用。",{"type":20,"tag":34,"props":657,"children":659},{"id":658},"响应设计",[660],{"type":26,"value":658},{"type":20,"tag":28,"props":662,"children":663},{},[664],{"type":26,"value":665},"统一状态码与错误结构、合理分页、字段命名一致、避免过深嵌套。",{"type":20,"tag":34,"props":667,"children":669},{"id":668},"最佳实践",[670],{"type":26,"value":668},{"type":20,"tag":28,"props":672,"children":673},{},[674],{"type":26,"value":675},"用 HTTPS、压缩响应、版本化、文档化字段含义。",{"type":20,"tag":34,"props":677,"children":678},{"id":56},[679],{"type":26,"value":56},{"type":20,"tag":60,"props":681,"children":683},{"className":62,"code":682,"language":64,"meta":7,"style":7},"{\"code\": 0, \"data\": {\"id\": 1}, \"message\": \"ok\"}\n",[684],{"type":20,"tag":67,"props":685,"children":686},{"__ignoreMap":7},[687],{"type":20,"tag":71,"props":688,"children":689},{"class":73,"line":74},[690,694,699,703,708,712,717,721,726,730,735,740,745,749,754],{"type":20,"tag":71,"props":691,"children":692},{"style":78},[693],{"type":26,"value":81},{"type":20,"tag":71,"props":695,"children":696},{"style":84},[697],{"type":26,"value":698},"\"code\"",{"type":20,"tag":71,"props":700,"children":701},{"style":78},[702],{"type":26,"value":92},{"type":20,"tag":71,"props":704,"children":705},{"style":84},[706],{"type":26,"value":707},"0",{"type":20,"tag":71,"props":709,"children":710},{"style":78},[711],{"type":26,"value":103},{"type":20,"tag":71,"props":713,"children":714},{"style":84},[715],{"type":26,"value":716},"\"data\"",{"type":20,"tag":71,"props":718,"children":719},{"style":78},[720],{"type":26,"value":405},{"type":20,"tag":71,"props":722,"children":723},{"style":84},[724],{"type":26,"value":725},"\"id\"",{"type":20,"tag":71,"props":727,"children":728},{"style":78},[729],{"type":26,"value":92},{"type":20,"tag":71,"props":731,"children":732},{"style":84},[733],{"type":26,"value":734},"1",{"type":20,"tag":71,"props":736,"children":737},{"style":78},[738],{"type":26,"value":739},"}, ",{"type":20,"tag":71,"props":741,"children":742},{"style":84},[743],{"type":26,"value":744},"\"message\"",{"type":20,"tag":71,"props":746,"children":747},{"style":78},[748],{"type":26,"value":92},{"type":20,"tag":71,"props":750,"children":751},{"style":95},[752],{"type":26,"value":753},"\"ok\"",{"type":20,"tag":71,"props":755,"children":756},{"style":78},[757],{"type":26,"value":122},{"type":20,"tag":34,"props":759,"children":760},{"id":125},[761],{"type":26,"value":125},{"type":20,"tag":129,"props":763,"children":764},{},[765,772],{"type":20,"tag":133,"props":766,"children":767},{},[768],{"type":20,"tag":137,"props":769,"children":770},{"href":147},[771],{"type":26,"value":147},{"type":20,"tag":133,"props":773,"children":774},{},[775],{"type":20,"tag":137,"props":776,"children":777},{"href":307},[778],{"type":26,"value":307},{"type":20,"tag":34,"props":780,"children":781},{"id":152},[782],{"type":26,"value":152},{"type":20,"tag":28,"props":784,"children":785},{},[786],{"type":26,"value":787},"RESTful 与 GraphQL API 普遍用 JSON 作为请求响应格式，本文介绍最佳实践。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":161,"props":789,"children":790},{},[791],{"type":26,"value":165},{"title":7,"searchDepth":167,"depth":167,"links":793},[794,795,796,797,798],{"id":658,"depth":167,"text":658},{"id":668,"depth":167,"text":668},{"id":56,"depth":167,"text":56},{"id":125,"depth":167,"text":125},{"id":152,"depth":167,"text":152},"content:blog:json-in-api.md","blog/json-in-api.md","blog/json-in-api",1787305466499]