如何在变量中放置带双引号,空格和括号的请求?(how do I put a request with double quotes, spaces and parenthesis inside a va

编程入门 行业动态 更新时间:2024-10-27 16:23:17
如何在变量中放置带双引号,空格和括号的请求?(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 answers

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.

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

更多推荐

本文发布于:2023-07-06 20:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1054519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:括号   空格   变量   双引号   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!