I have a Windows Service that frequently monitors the .json file structure, it has always worked correctly until yesterday where this .json could not be read correctly by our applications but was considered as valid!:
{
"infohead": {
"indicator": "12",
"istesting": "ABC_12_219",
"isdate": "2021-08-11 10:02:12"
},
"headers": {
"url": "https://www.blahblah.com/"
},
"advertisements": [,
{
"type": "arc",
"adType": "1",
"appn": {
"x": 1241,
"y": 1241,
"z": 1243,
}
},
{
"type": "arc2",
"adType": "1",
"appn": {
"x": 1441,
"y": 1441,
"z": 1443,
}
}
]
}
if it loads in a browser I get the error:
SyntaxError: JSON.parse: unexpected character at line 10 column 21 of the JSON data
C # somehow detects that this is correct, the array "advertisements" has three objects, one with a empty value and the other with a value.
"advertisements": [,
{
"type": "arc",
"adType": "1",
"appn": {
"x": 1241,
"y": 1241,
"z": 1243,
}
},
{
"type": "arc2",
"adType": "1",
"appn": {
"x": 1441,
"y": 1441,
"z": 1443,
}
}
]
I have also used the methods described in this question,
How to make sure that string is valid JSON using JSON.NET
I didn´t want to validate using a JSON schema (Validate Json schema C#), there is another solution to perform the validation?