JSON Validator giving me error - json

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.

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.

Google fit API add multiple data type based on scope

I am using google fit API with multiple user scopes. How can I add multiple data type for each source. If possible, why I cannot add this as a datasource.
{
"dataStreamName":"MyDataSource",
"type":"derived",
"application":{
"detailsUrl":"http://example.com",
"name":"Foo Example App",
"version":"1"
},
"dataType":[
{
//1st data type
"name":"com.google.step_count.delta",
"field":[
{
"name":"steps",
"format":"int"
}
]
},
{
//2nd data type
"name":"com.google.calories.bmr",
"field":[
{
"name":"calories",
"format":"float"
}
]
}
],
"device":{
"manufacturer":"Example Manufacturer",
"model":"ExampleTablet",
"type":"tablet",
"uid":"1000001",
"version":"1.0"
}
}
And I got a response of
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"dataType\" at 'data_source': Proto field is not repeating, cannot start list.",
"errors": [
{
"message": "Invalid JSON payload received. Unknown name \"dataType\" at 'data_source': Proto field is not repeating, cannot start list.",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}
But when I only add one scope which is like this
{
"dataStreamName":"MyDataSource",
"type":"derived",
"application":{
"detailsUrl":"http://example.com",
"name":"Foo Example App",
"version":"1"
},
"dataType":{
"name":"com.google.step_count.delta",
"field":[
{
"name":"steps",
"format":"integer"
}
]
},
"device":{
"manufacturer":"Example Manufacturer",
"model":"ExampleTablet",
"type":"tablet",
"uid":"1000001",
"version":"1.0"
}
}
It returns me 200 which is successful. Did I miss something or is what I am trying to do possible? Thanks.
Google fit API reference
https://developers.google.com/fit/rest/v1/reference/users/dataSources/create
I believe the nesting your trying to do has to go at the dataField level rather than the dataType level.
dataType.field[]
I think this because I noticed that 'field[]' is a collection while dataType is not.

Cannot parse config file using grunt command for execution

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"
}
}

Error in Targeting Company Shares Using JSON

I'm trying to Target company shares (https://developers.linkedin.com/documents/targeting-company-shares) using json with LinkedIn Rest Api.
My JSON object (https://developers.linkedin.com/forum/targeting-example-using-multiple-targeting-parameters-and-json) looks like :
{
"visibility": {
"code": "anyone"
},
"comment": "Targeting Shares",
"share-target-reach": {
"share-targets": {
"share-target": [{
"code": "geos",
"tvalues": {
"tvalue": "as"
}
}, {
"code": "companySizes",
"tvalues": {
"tvalue": "201-500"
}
}]
}
}
}
But this isn't working, i'm getting the following error :
{
"errorCode": 0,
"message": "Malformed json document. Encountered unexpected array.",
"requestId": "DRWYRUVMBJ",
"status": 400,
"timestamp": 1423283491818
}
I'm not able to figure out where's the problem??
I have been playing around with this for awhile now and near as I can tell the below format will work. Basically you have to remove all the arrays, I have tried them at every level and they always cause the malformed json error. I still have no idea how to target multiple sections at once though, since the official documentation on this is very wrong. The only way I figured this part out is by doing a whole lot of guessing.
{
"visibility": {
"code": "anyone"
},
"comment": "Targeting Shares",
"share-target-reach": {
"share-targets": {
"share-target": {
"code": "geos",
"tvalues": {"tvalue": "as"}
}
}
}