angular2 是否可以返回原始 json 响应?前任。
零件
getrawJson(){
this.someservice.searchJson()
.subscribe( somelist => this.somelist = somelist,
error => this.errorMsg = <any>error);
}
为服务
searchJson(num: number, somestring: string, somestring2: string): Observable<stringDataObj> {
let body = JSON.stringify({"someJsonData"[{num, somestring, somestring2}]});
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(URL, body, options)
.map(this.jsonObj)
.catch(this.handleError);
}
private jsonObj(res: Response) {
let body;
return body{ };
}
上述实现返回 Array 。我有办法获取服务返回的原始 json 数据吗?我期待有如下的json响应
{“dataParam”:[{“num”:“08”,“somestring”:“2016-10-03”,“somestring2”:“2016-10-03”}],“someDatalist”:[{“one” :“08”,“二”:1,“三”:“2016-10-03”}]}
谢谢!