This question already has an answer here:
这个问题在这里已有答案:
- Encoding Javascript Object to Json string 2 answers
将Javascript对象编码为Json字符串2个答案
I 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.
我想将它存储在变量/对象中,如var request =“{... {..} ..}”;我该怎么做?由于{}和双引号我有错误。
I'm a novice sorry for my poor explanation. :)
1 个解决方案
#1
0
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);
#1
0
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);