[英]how to get remove \ from json response
如何从responseJson的路径值中删除\\
{"records": [{
"id":"1",
"title":"React Native",
"description":"Complete React Native course for advanced",
"instructor":"john",
"chapter":"15",
"assignment":"15",
"fees":"799",
"course":"SampleVideo_1280x720_5mb.mp4",
"thumbnail":"158347549716062111655e61eb296f7fd.jpg",
"path":"http:\/\/localhost:8080\/coursePHP\/upload\/158347549716062111655e61eb296f7fd.jpg"
}]}
这是我得到的 json 数据我需要来自路径 fetchData(){ 的 url
return fetch('http://192.168.0.104:8080/api/product/displayCourse.php',{
method: 'POST',
headers: {'Accept': 'application/json','Content-Type': 'application/json'},
})
.then((response) => response.json() )
.then( (responseJson) => {
this.setState({
dataSource: responseJson.records
});
//dataurl = JSON.parse(this.responseJson.records.thumbnail);
})
.catch((error) => {
console.error(error.message);
})
}
在这里试试这个。
let path = responseJson.records[0].path;
删除正斜杠\\
path = path.replace("\\","");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.