Am newbie to Json
am getting this error while call json my json file expected ',' or ']'
[
{
"modules":
[
{
"title":"name of module1",
"description":"description of module1",
"weeks":[{"id":1, "title":"Week 01"}]
},
{
"title":"name of module2",
"description":"description of module2",
"weeks":[{"id":2, "title":"Week 02"},{"id":3,"title":"Week 03"}]
}
]
},
{
"products":
[
{
"url":"http://dummyimage.com/242x200/f3f3f3/2d2d2d.png",
"description":"Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.",
"viewurl" : "/",
"savebtn" : "save"
},
{
"url":"http://dummyimage.com/242x200/f3f3f3/2d2d2d.png",
"description":"Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.",
"viewurl" : "/",
"savebtn" : "save"
}
]
}
]
hope i did correct i dont know what is happening its getting Error: JSON.parse: expected ',' or ']' after array element
am attempting to use in angular js controller
app.controller('settingsController', function($scope, $http){
$http.get('assets/javascripts/datas.json').then(function(result){
$scope.employe = result.data;
$scope.prod = result
})
});
and in view
<div class="col-sm-6 col-md-4" ng-repeat="datas in prod.products">
<div class="thumbnail">
<img ng-src="{{ datas.url }}" alt="product">
<div class="caption">
<h3>{{ datas.caption}} </h3>
<p>{{ datas.description}}</p>
<p><a role="button" class="btn btn-primary" ng-href="{{datas.viewurl}}">Button</a> <a role="button" class="btn btn-default" href="#">{{datas.savebtn}}</a></p>
</div>
</div>
</div>
and the error in console
Error: JSON.parse: expected ',' or ']' after array element at line 76 column 9 of the JSON data cc@/test/assets/javascripts/vendors/angular.js:14:289 Ud/this.defaults.transformResponse<@/test/assets/javascripts/vendors/angular.js:69:58 xc/<@/test/assets/javascripts/vendors/angular.js:68:352 r@/test/assets/javascripts/vendors/angular.js:7:288 xc@/test/assets/javascripts/vendors/angular.js:68:336 b@/test/assets/javascripts/vendors/angular.js:70:65 ye/e/l.promise.then/K@/test/assets/javascripts/vendors/angular.js:100:59 ye/f/<.then/<@/test/assets/javascripts/vendors/angular.js:101:235 Zd/this.$get
JSON.parse
? – Phil Sep 5 at 5:35$httpProvider
? If so, what does it look like? – Phil Sep 5 at 5:46assets/javascripts/datas.json
? Check your browser's Network developer console and inspect the server response for that file to make sure it matches exactly – Phil Sep 5 at 5:52