Cannot parse config file using grunt command for execution - json

I'm getting an error while working with grunt,
Error cannot parse config file unexpected token in default.json
I tried correcting the code but I'm receiving the same error
This is my default.json file:
{
"Amazon" : {
"lambda-arn" : "arn:aws:lambda:us-east-1:286506727102:function:myPandora",
},
"Pb": {
"url": "https://aiaas.xxx",
"app_id": "1xxxx1",
"user_key": "070xxxxxx",
"botname": "alexa"
},
}
Please help me with this error, Thank you.

Delete the commas at the end of lines 3 and 10 in your JSON to make it valid. E.g.
{
"Amazon": {
"lambda-arn": "arn:aws:lambda:us-east-1:286506727102:function:myPandora"
},
"Pb": {
"url": "https://aiaas.xxx",
"app_id": "1xxxx1",
"user_key": "070xxxxxx",
"botname": "alexa"
}
}

Related

How to change JSON file to be readable?

I've created a JSON.
This JSON file will be a source of query in ElasticSearch
This query works in ElasticSearch and returns results.
When I store the query to JSON, I see that JSON is valid. But when I read it from JSON I have an error.
It's my JSON:
{
"function_score": {
"query": {
"bool": {
"should": [
{
"query_string": {
"default_field": "headline",
"query": "engineer"
}
},
{
"match_all": {}
}
]
}
},
"functions": [
{
"script_score": {
"script": {
"params": {
"queryVector": [1,2,5],
"max_score": "max_score"
},
"source": "if (_score>0 && params.max_score>0){return doc['embedding_headline'].size() == 0 ? 0 : Math.min(Math.max(_score/params.max_score,cosineSimilarity(params.queryVector, 'embedding_headline')),1) + 1.0} else { return doc['embedding_headline'].size() == 0 ? 0 : cosineSimilarity(params.queryVector, 'embedding_headline') + 1.0}",
"lang": "painless"
}
}
}
],
"score_mode": "max",
"boost_mode": "replace",
}
}
I use python for reading JSON.
It's code for reading:
import json
file_path = 'queries.json'
with open(file_path) as f:
data = json.load(f)
print(data)
It's error:
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 34 column 5 (char 1012)
What should I change in this JSON to make it readable?
Thanks
That json is invalid.
I just pasted it into a json validator and it has errors in it.
CHeck this link:
json lint
Paste your json there, it throws the following errors:
Error: Parse error on line 30:
..._mode": "replace", }}
----------------------^
Expecting 'STRING', got '}'
If you are using python it often throws errors due to string quotation as well.
Try to enclose the script source field in single quotes instead of doubles. That could be another problem.
Last but not the least, function score queries are extremely slow, and I would recommend not using them!

How do I fix this JSON Code? I am getting an "undefined" error

I am very new to JSON (as in a few days into using it) and I can't get my head around what is wrong with this code. I have copy/pasted it and modified it to my needs carefully a few times and I am still getting this error code:
Error: Parse error on line 3:
... "product_id": { Product: Id }, "
----------------------^
Expecting 'STRING', '}', got 'undefined'
Here is my code:
{
"image": {
"product_id": {
Product: Id
},
"position": 1,
"src": {
GWP Variant Image
},
"variant_ids": [{
Variants: Id
}]
}
}
PS: I hope I understood the post formatting instructions correctly. This is my first post.

eslint error in html file: Parsing error: Unexpected token <

why eslint give me this error
Parsing error: Unexpected token < in html file?
how can i solve this error?
my .eslint.json configs:
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": [
"airbnb-base"
],
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"strict": "off"
}
}
you need eslint-plugin-html to lint html file. the details can be found in this link: https://www.npmjs.com/package/eslint-plugin-html
Adding the below to ".eslintrc.json" file worked for me:
"ignorePatterns": [
"**/*.html"
]
One other option can be to add an .eslintignorefile. See the exmple below.
.eslintignore
.vscode/*
dist/*
assets/*
node_modules/*
**/index.html
**/index.*.html
**/assets/*.html

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:
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 CopyWebpackPlugin but the project doesn't use any Webpack configuration file.
then, following 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 ?
Inspired by #AndrewJuniorHoward, found that while upgrade process, all the json files were encoded to UTF-8-BOM instead of UTF-8, that's why Angular was unable to load them during build.
In Visual Studio code, I just created empty files, pasted in them the content of the old json files and then overwritten them, and all worked perfectly.
Resave the angular.json file as UTF8. There seems to be a recent problem with upgrading to Angular 6 regarding this.
Hope you have resolved the issue but still if you want some minor changes you can try adding "id" to objects in array as below, I Tried this in my CLI project on Angular 6 while performing CURD operation in JSON file.
{
"menu":[
"app": {
"id": 1,
"Welcome": "Welcome",
"New": "New"
},
"mainMenu": {
"id": 2,
"Home": "Home",
"Logout": "Logout"
},
"pageHeader": {
"id": 3,
"About": "About",
"Settings": "Settings"
}
]
}

JSON Validator giving me error

I'm trying to parse deploy but I'm getting an error. The global.json is:
{
"applications": {
”MyApp”: {
"applicationId": "7OI1Gk555Tr1CnrQ8bqplgImxMDJFTFfxaYUaPAZ",
"masterKey": "Udzp2AaPb7WLg3aYtHqRyShliJU3nV98ak3P6IGi"
},
"_default": {
"link": ”MyApp”
}
},
"global": {
"parseVersion": "1.3.1"
}
}
JSON Validator is giving me the error:
Parse error on line 2:
...cations": { ”MyApp”: {
----------------------^
Expecting 'STRING', '}'
instead of ”MyApp” use "MyApp" it will work fine.the first one is not parse-able to json because it will not treat it as string as shown in your error stated.