我收到了这样的回复:
/*-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-
,从响应结束时删除*/
。
答案 0 :(得分:1)
应该是一个简单的替换:
var resp = <string>;
resp = resp.replace(/^\/\*\-secure\-\n/, '').replace(/\*\/$/, '');
答案 1 :(得分:1)
我得到了答案:
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);
其中数据是你获得响应的任何字符串。