Wednesday, 20 December 2017

Angular 6 - Unexpected token in JSON at position 0

My Angular 5 project was working without issues, just
after having updated it to version 6, it stopped building using ng
build
due to the next:



readability="6">

ERROR in ./src/app/assets/i18/en.json
Module parse failed: Unexpected
token in JSON at position 0 You may need an
appropriate loader to
handle this file
type.




here is my
json
file:



{
"app":
{
"Welcome": "Welcome",

"New": "New"

},
"mainMenu": {
"Home": "Home",
"Logout":
"Logout"
},
"pageHeader": {
"About":
"About",
"Settings": "Settings"

}

}


Most
solutions on the web are talking about href="https://github.com/webpack-contrib/copy-webpack-plugin" rel="nofollow
noreferrer">CopyWebpackPlugin but the project doesn't use any Webpack
configuration file.



then, following href="https://stackoverflow.com/questions/5034444/can-json-start-with?answertab=active#tab-top">this
link I tried to make the json as an
array:



{

"menu":[
"app": {

"Welcome": "Welcome",

"New": "New"
},
"mainMenu": {
"Home":
"Home",
"Logout": "Logout"
},
"pageHeader":
{
"About": "About",
"Settings": "Settings"


}

]
}


But got
the following error, despite the file contains 16
lines.





Unexpected token : in JSON at position
24





Any
idea ?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...