[
{
"Intent":"what is manufacturer name?",
"Entity":"Name",
"Response":"Test",
"Status":"0",
"Created_Date":"2017-04-04T00:00:00",
"Response_Count":0,
"Response_Count_string":0
},
{
"Intent":"hi",
"Entity":"hi",
"Response":"hiiii",
"Status":"0",
"Created_Date":"2017-03-28T10:22:00",
"Response_Count":0,
"Response_Count_string":0
},
{
"Intent":"how are you?",
"Entity":"are you fine",
"Response":"good!cool",
"Status":"1",
"Created_Date":"2017-03-28T10:22:38",
"Response_Count":0,
"Response_Count_string":0
}
]
最佳答案
从JSON String读取数据的方式:
1.使用Javascript
var jsonStr = "[{\"Intent\":\"what is manufacturer name?\",\"Entity\":\"Name\",\"Response\":\"Test\",\"Status\":\"0\",\"Created_Date\":\"2017-04-04T00:00:00\",\"Response_Count\":0,\"Response_Count_string\":0},{\"Intent\":\"hi\",\"Entity\":\"hi\",\"Response\":\"hiiii\",\"Status\":\"0\",\"Created_Date\":\"2017-03-28T10:22:00\",\"Response_Count\":0,\"Response_Count_string\":0},{\"Intent\":\"how are you?\",\"Entity\":\"are you fine\",\"Response\":\"good!cool\",\"Status\":\"1\",\"Created_Date\":\"2017-03-28T10:22:38\",\"Response_Count\":0,\"Response_Count_string\":0}]";
var jsonObj = JSON.parse(jsonStr);
for (var i in jsonObj) {
console.log(jsonObj[i].Intent);
}
2.使用AngularJS
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl',function($scope) {
var jsonStr = "[{\"Intent\":\"what is manufacturer name?\",\"Entity\":\"Name\",\"Response\":\"Test\",\"Status\":\"0\",\"Created_Date\":\"2017-04-04T00:00:00\",\"Response_Count\":0,\"Response_Count_string\":0},{\"Intent\":\"hi\",\"Entity\":\"hi\",\"Response\":\"hiiii\",\"Status\":\"0\",\"Created_Date\":\"2017-03-28T10:22:00\",\"Response_Count\":0,\"Response_Count_string\":0},{\"Intent\":\"how are you?\",\"Entity\":\"are you fine\",\"Response\":\"good!cool\",\"Status\":\"1\",\"Created_Date\":\"2017-03-28T10:22:38\",\"Response_Count\":0,\"Response_Count_string\":0}]";
$scope.jsonObj = JSON.parse(jsonStr);
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
<div ng-repeat="item in jsonObj">
{{item.Intent}}
</div>
</div>