React Native 格式 cookie

我有一个看起来像这样的 cookie:

{"SSOsess":"300|c6dc6d60ebebf0891004353352f24b77","RTBk":"300|451706000c67a37dfe5bebe0b5d26278","ph02RPNCiscoASA":"application.api.randwebsite.com","ph03RPNCiscoASA":"application.client.randwebsite.com"}

是否有任何库可以帮助我将字符串格式化为以下内容:

'SSOsess=300|c6dc6d60ebebf0891004353352f24b77; RTBk=300|451706000c67a37dfe5bebe0b5d26278; ph02RPNCiscoASA=application.api.randwebsite.com; ph03RPNCiscoASA=application.client.randwebsite.com'

我一直在查看set-cookie-parser但看起来它不包含任何有用的功能。


catspeake
浏览 105回答 1
1回答

小唯快跑啊

尝试这个。let cookie = JSON.stringify({"SSOsess":"300|c6dc6d60ebebf0891004353352f24b77","RTBk":"300|451706000c67a37dfe5bebe0b5d26278","ph02RPNCiscoASA":"application.api.randwebsite.com","ph03RPNCiscoASA":"application.client.randwebsite.com"})var output = cookie.split(":").join("=").split(',').join("; ")output = "'"+output.substring(1,output.length-1).replace(/"/g, "")+"'"console.log(output)//输出'SSOsess=300|c6dc6d60ebebf0891004353352f24b77; RTBk=300|451706000c67a37dfe5bebe0b5d26278; ph02RPNCiscoASA=application.api.randwebsite.com; ph03RPNCiscoASA=application.client.randwebsite.com'
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript