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