[英]How to remove string from the json response
我收到这样的回复:
/*-secure-{"errors":["Runtime: Adapter 'DemoAdapter' does not exist"],"isSuccessful":false,"warnings":[],"info":[]}*/
但是我只想要响应中的JSON数据。 像这样:
{
"errors": ["Runtime: Adapter 'DemoAdapter' does not exist"],
"isSuccessful": false,
"warnings": [],
"info": []
}
如何删除/*-secure-
从一开始就和*/
从响应结束。
应该是一个简单的替换:
var resp = <string>;
resp = resp.replace(/^\/\*\-secure\-\n/, '').replace(/\*\/$/, '');
我得到了答案:
var str = '/*-secure-{"errors":["Runtime: Adapter "DemoAdapte" does not exist"],"isSuccessful":false,"warnings":[],"info":[]}*/';
var res = str.substring(10,str .length-2);
语法是这样的。
var str = data;
var res = str.substring(10,str .length-2);
数据是任何字符串,您都会得到响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.