• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Javascript generated JSON vs CF generated JSON

LEGEND ,
Dec 14, 2015 Dec 14, 2015

Copy link to clipboard

Copied

Hello, all,

I've got a few pages that I'm working on where, after the page loads, I use Javascript to dynamically create a form, then use CF to convert a query object to JSON, insert that into the form, and submit it (as opposed to running the same query twice), and the action page will DeserializeJSON()  to generate an Excel spreadsheet from the query.

These pages are all working flawlessly.

Now, I'm trying to do the same thing, except insead of using CF to convert a query into JSON, I'm creating a Javascript JSON of the data to pass to the form.  But when the page submits, DeserializeJSON() isn't working, even though I'm using the same format that CF uses.

I'm getting the following error:

JSON parsing failure: Expected ',' or ']' at character 60721:'M' in ... (JSON string)

Well, at almost 100,000 characters, I'm having trouble finding that position (Word is useless for this), so can't view the issue directly.  However, I'm wondering if anyone knows a way to take a Javascript JSON string and format it so that CF can deserialize it.

V/r,

^_^

Views

213

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 14, 2015 Dec 14, 2015

Copy link to clipboard

Copied

Nevermind.. I figured it out.

I copied and pasted the JSON string into a JS variable, created a div and gave it an id="testJSON" attribute, then:

document.getElementById('testJSON').innerHTML = jsVar.substr(60700,60750);

I noticed, now, that someone had used double quotes as part of a cell value, and that was throwing my Javascript generated JSON out of whack.

I applied a .replace(/"/gi,'"') to the values, and that mostly fixed it.  However, the cells where there is a double quote now show up in the Excel spreadsheet as ";

For now, not a big deal.  Although if anyone can help fix it by removing the semi-colon after a " (CF is doing a replacenocase(""",'"') and that isn't removing the ; for some reason.)

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2015 Dec 15, 2015

Copy link to clipboard

Copied

LATEST

Possibly related to my post here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation