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. 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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.