I use nodejs & expressjs for my backend, Angular for my front-end. When using Angular translate in my site, the console shows this message:
Error: JSON Parse error: Property name must be a string literal
parse@[native code]
fromJson@http://localhost:3000/angular/angular.js:1321:19
defaultHttpResponseTransform@http://localhost:3000/angular/angular.js:10393:24
http://localhost:3000/angular/angular.js:10484:14
forEach@http://localhost:3000/angular/angular.js:322:24
transformData@http://localhost:3000/angular/angular.js:10483:10
transformResponse@http://localhost:3000/angular/angular.js:11278:34
processQueue@http://localhost:3000/angular/angular.js:15961:30
http://localhost:3000/angular/angular.js:15977:39
$eval@http://localhost:3000/angular/angular.js:17229:28
$digest@http://localhost:3000/angular/angular.js:17045:36
$apply@http://localhost:3000/angular/angular.js:17337:31
done@http://localhost:3000/angular/angular.js:11572:53
completeRequest@http://localhost:3000/angular/angular.js:11778:15
requestLoaded@http://localhost:3000/angular/angular.js:11711:24
I am sure that all properties in JSON files are quoted.
This is the locale files:
{
"directives.language-select.Language": "Select Language",
"views.video-modal.Download": "Download",
"views.video-modal.Visit": "Visit",
"views.video-modal.Copy": "Copy",
"views.video-modal.Close": "Close",
}
Strangely, when I only had
"directives.language-select.Language": "Select Language",
this line. The site worked perfectly. What causes this problem?
I use nodejs & expressjs for my backend, Angular for my front-end. When using Angular translate in my site, the console shows this message:
Error: JSON Parse error: Property name must be a string literal
parse@[native code]
fromJson@http://localhost:3000/angular/angular.js:1321:19
defaultHttpResponseTransform@http://localhost:3000/angular/angular.js:10393:24
http://localhost:3000/angular/angular.js:10484:14
forEach@http://localhost:3000/angular/angular.js:322:24
transformData@http://localhost:3000/angular/angular.js:10483:10
transformResponse@http://localhost:3000/angular/angular.js:11278:34
processQueue@http://localhost:3000/angular/angular.js:15961:30
http://localhost:3000/angular/angular.js:15977:39
$eval@http://localhost:3000/angular/angular.js:17229:28
$digest@http://localhost:3000/angular/angular.js:17045:36
$apply@http://localhost:3000/angular/angular.js:17337:31
done@http://localhost:3000/angular/angular.js:11572:53
completeRequest@http://localhost:3000/angular/angular.js:11778:15
requestLoaded@http://localhost:3000/angular/angular.js:11711:24
I am sure that all properties in JSON files are quoted.
This is the locale files:
{
"directives.language-select.Language": "Select Language",
"views.video-modal.Download": "Download",
"views.video-modal.Visit": "Visit",
"views.video-modal.Copy": "Copy",
"views.video-modal.Close": "Close",
}
Strangely, when I only had
"directives.language-select.Language": "Select Language",
this line. The site worked perfectly. What causes this problem?
Share Improve this question asked Apr 19, 2016 at 1:20 Joshua LeungJoshua Leung 2,3998 gold badges33 silver badges56 bronze badges3 Answers
Reset to default 20Ok, a thought just came up and I found out that you are not supposed to put ',' at the end of the very last line. Deleting the ',' solved my problem.
For those who encounter this problem, you may try this.
I just running into this problem when try to return a JSON back from the PHP server. And turn out JSON does not allow trailing comma. Stating in the JSON Specification
When editing json files by hand, you should test your content through https://jsonlint.com