I am trying to pass the JSON data in the value of cfhttpparam
as follows:
Line #95: <cfhttpparam type="formfield"
name="seriesofdata"
value="[{"Id": 118,"Value": 1,"Desc": "Checking Description ","Group": 1}]"/>
But I keep on getting the following error:
Invalid token " found on line 95 at column XX.
I have checked the JSON and it's valid JSON that I am passing as a value.
What am I doing wrong?
So this is certainly valid JSON:
{"Id": 118,"Value": 1,"Desc": "Checking Description ","Group": 1}
However you're wrapping it inside " "
so the first "
in your JSON packet will look like a closing "
to the cfhttpparam value
<cfhttpparam type="formfield" name="seriesofdata" value="[{"Id": 118,"Value": 1,"Desc": "Checking Description ","Group": 1}]"/>
^
Looks to CF like you're doing:
<cfhttpparam
type="formfield"
name="seriesofdata"
value="[{"
Id": 118,"Value": 1,"Desc": "Checking Description ","Group": 1}]"
/>
That whole last bit just looks like garbage, hence the 'Invalid token' error.
Just either escape those " or use single-quotes instead, either in the JSON or in the CFML.
<cfhttpparam type="formfield" name="seriesofdata" value='[{"Id": 118,"Value": 1,"Desc": "Checking Description ","Group": 1}]'>