Recently, I encountered issues with my browser while parsing JSON return data from the server. Initially, I assumed it was related to my specific data, but even a simple example like
{"a": 1}
led to an error "invalid label" in Firefox and "SyntaxError: Unexpected token :" in Chrome. Interestingly, when I removed the double quotes around the label as shown below:
{a:1}
(eliminating the double quote marks), the issue disappeared. However, I am confident that the JSON is valid even with the double quotes (as validated by JSONLint).
The workaround recommended was wrapping the JSON object with brackets like this:
({"a":1})
This solution worked in the browser console, but not when attempting to modify the server data in response to a JSONP call. Unfortunately, due to using a library (Dojo), I didn't have the ability to intercept the parsed data before its processing.
UPDATE
Upon further investigation, I discovered a bug in my server code where the data wasn't properly enclosed in a JavaScript function for the JSONP response. This adjustment resolved the issue, and consequently, I will be removing this question. My apologies, and thank you for the responses provided nevertheless.