JSON format issue?
I am debugging a perl module that generates JSON and what I know about JSON you could probably fit in a thimble. The JSON is here.....
xvarStore_json = {
identifier: 'name',
label: 'name',
items: [
{name: "CR_Local_ID"} ,
{name: "CR_Patient_ID"} ,
开发者_Python百科 {name: "test("MEDICARE PART B","xvar:X_Primary_Payer","1","1")"}
]
};
The error I am getting in Firebug is ..
missing } after property list
{name: "test("MEDICARE PART B","xvar:X_Primary_Payer","1","1")"}
I would be happy to spend the time learning JSON if this weren't an urgent fix. Does anyone have an idea as to what's going wrong?
Janie
While I agree @matt-ball in his answer, I don't think that's really the issue here. The problem is this line:
{name: "test("MEDICARE PART B","xvar:X_Primary_Payer","1","1")"}
You need to escape your quotes inside the actual value:
{name: "test(\"MEDICARE PART B\",\"xvar:X_Primary_Payer\",\"1\",\"1\")"}
That's not JSON; it is a JavaScript object literal. There is a very important difference.
The syntax highlighting gives away the problem: you're trying to use double quotes inside of a string that's delimited by double-quotes, so the string ends early. Just use single quotes to delimit the string instead.
{name: 'test("MEDICARE PART B","xvar:X_Primary_Payer","1","1")'}
And just to make it perfectly clear, there's no such thing as a "JSON object."
Issue withe the unterminated quotes:
Replace with {name: "test("MEDICARE PART B","xvar:X_Primary_Payer","1","1")"} with
{name: "test('MEDICARE PART B','xvar:X_Primary_Payer','1','1')"}
Your JSON object should look like:
xvarStore_json = {
identifier: 'name',
label: 'name',
items: [
{name: "CR_Local_ID"} ,
{name: "CR_Patient_ID"} ,
{name: "test('MEDICARE PART B','xvar:X_Primary_Payer','1','1')"}
]
};
精彩评论