如何在变量中放置带双引号,空格和括号的请求?(how do I put a request with double quotes, spaces and parenthesis inside a variable ? javascript [duplicate])
这个问题在这里已有答案:
将Javascript对象编码为Json字符串 2个答案我有这样的事情:
{ "urn.getxxxx": { "urn.xxxx": "cxxxxx-44e9-xxxx-a91b-0000xxxx\\xxxxx\\3239750\\EO\\0\\", "urn.xxxx": "xxxxx", "urn.xxxxx": "x", "urn.xxxx": "2016-07-08T13:03:41+02:00" } }我想将它存储在变量/对象中,如var request = "{...{..}..}"; 我该怎么做? 由于{}和双引号我有错误。
I'm a novice sorry for my poor explanation. :)This question already has an answer here:
Encoding Javascript Object to Json string 2 answersI have something like this:
{ "urn.getxxxx": { "urn.xxxx": "cxxxxx-44e9-xxxx-a91b-0000xxxx\\xxxxx\\3239750\\EO\\0\\", "urn.xxxx": "xxxxx", "urn.xxxxx": "x", "urn.xxxx": "2016-07-08T13:03:41+02:00" } }and i want to store it in a variable/object like var request = "{...{..}..}"; how do I do it? I have errors becouse of the {} and the doublequotes.
I'm a novice sorry for my poor explanation. :)最满意答案
var myObj = { "urn.getxxxx": { "urn.xxxx": "cxxxxx-44e9-xxxx-a91b-0000xxxx\\xxxxx\\3239750\\EO\\0\\", "urn.xxxx": "xxxxx", "urn.xxxxx": "x", "urn.xxxx": "2016-07-08T13:03:41+02:00" } }; var request = JSON.stringify(myObj);Stringify JSON
var myObj = { "urn.getxxxx": { "urn.xxxx": "cxxxxx-44e9-xxxx-a91b-0000xxxx\\xxxxx\\3239750\\EO\\0\\", "urn.xxxx": "xxxxx", "urn.xxxxx": "x", "urn.xxxx": "2016-07-08T13:03:41+02:00" } }; var request = JSON.stringify(myObj);Stringify JSON
更多推荐
发布评论