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