0

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?

1 Answer 1

7

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}]'>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.