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