[英]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.