Skip to content
Advertisement

Error: JSON Parse error: Property name must be a string literal when using angular translate

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?

Advertisement

Answer

Ok, 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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement