js解析jwt中的数据
emer 发布于 2020-12-2 14:44 1578 次阅读
var token='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ7XCJzYWx0XCI6XCJpYW1cIixcIm5hbWVcIjpcImFkbWluXCIsXCJ1c2VyTmFtZVwiOlwiYWRtaW5cIixcInN0YXR1c1wiOlwiRU5BQkxFRFwifSIsImV4cCI6MTYwNjg5MjE2OSwiaWF0IjoxNjA2ODkxMzA1fQ.j9E9v4SKIY4Fd49ywHiEvU3Ie163VR9GXSpf4lNBKjs'; let strings = token.split(".");
console.log(JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, "+").replace(/_/g, "/"))))))