Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用node.js从json中删除单引号_Jquery_Node.js - Fatal编程技术网

Jquery 使用node.js从json中删除单引号

Jquery 使用node.js从json中删除单引号,jquery,node.js,Jquery,Node.js,我有一根这样的绳子 var record ={ '"test":"Connect_Disconnect","jobid": "65","os":"Windows NT","report":"Verify Wireless Interface present and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not P

我有一根这样的绳子

var record ={ '"test":"Connect_Disconnect","jobid": "65","os":"Windows NT","report":"Verify Wireless Interface present and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OK<br>"': '' }
我想要一个如下的输出

{
  "test": "Connect_Disconnect",
  "jobid": "65",
  "os": "Windows NT",
  "report": "Verify Wireless Interface present and state is Disconnected:OK<br>Verify Profile not present on the Client:OK<br>Add Profile to the Client:OK<br>Verify Profile Added Present on the Client:OK<br>Connecting to Access Point:OK<br>Verify the State is Connected:OK<br>Disconnecting from Access Point:OK<br>Verify the State is Disconnected:OK<br>Delete Profile to the Client:OK<br>Verify Profile Not Present on the Client:OK<br>"
};
{
“测试”:“连接\断开连接”,
“jobid”:“65”,
“操作系统”:“Windows NT”,
“报告”:"验证无线接口是否存在且状态是否已断开:确定
验证客户端上不存在配置文件:确定
将配置文件添加到客户端:确定
验证客户端上是否存在添加的配置文件:确定
连接到接入点:确定
验证状态是否已连接:确定
从接入点断开:确定
验证状态是否已断开:确定
删除Pr客户端的配置文件:确定
验证客户端上不存在配置文件:确定
“ };
全局对象有一个
parse
方法,该方法将生成所需的输出。之所以没有在node.js中记录此方法,是因为它是语言的一部分

var record = JSON.parse('{"test":"Connect_Disconnect","jobid": "65","os":"Windows NT","report":"Verify Wireless Interface present and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OK<br>"}');
var record=JSON.parse(“{”test:“Connect_Disconnect”,“jobid:“65”,“os:“windowsnt”,“report:“验证无线接口存在且状态已断开:确定
验证客户端上不存在配置文件:确定客户端:确定
验证客户端上不存在配置文件:确定
”);
(注意,
{}
被添加来包装整个字符串)。

尝试以下操作:

var record ={ '"test":"Connect_Disconnect","jobid": "65","os":"Windows NT","report":"Verify Wireless Interface present and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OK<br>"': '' }
for(var key in record) { // get your string from original json object
    break;
}
record = JSON.parse('{' + key + '}'); // parse string to new json object
var record={'“test”:“Connect_Disconnect”,“jobid”:“65”,“os”:“Windows NT”,“report”:“验证无线接口存在且状态已断开:确定
验证客户端上不存在配置文件:确定客户端:确定
验证客户端上不存在配置文件:确定
”:'} 对于(记录中的var key){//从原始json对象获取字符串 打破 } record=JSON.parse('{'+key+'}');//将字符串解析为新的JSON对象
你能澄清你想删除哪个单引号吗?record是一个对象而不是字符串,它唯一的键看起来像JSON字符串,而且据我所知,它不包含单引号。是的,我想删除单引号,因为josn stringam从我这里得到错误
未定义:1^语法错误:意外标记o
+1。Extr在我看来,从带有
for
循环的对象中执行JSON看起来有点奇怪。我们应该真正知道OP在干什么。另外,从这一点上,我如何获得jobid和testwith record.test和record.jobid的值。您还可以使用record['test']
var record ={ '"test":"Connect_Disconnect","jobid": "65","os":"Windows NT","report":"Verify Wireless Interface present and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OK<br>"': '' }
for(var key in record) { // get your string from original json object
    break;
}
record = JSON.parse('{' + key + '}'); // parse string to new json object