Copy link to clipboard
Copied
I have some valid JSON data that's being converted successfully by DeserializeJSON... until it gets to a certain size, or that's certainly what appears to be happening. The breaking point seems to be somewhere in the neighborhood of 35,000 characters... about 35KB. When the conversion fails, it fails with a "JSON parsing failure: Unexpected end of JSON string" message. And when the conversion fails, the JSON data is deemed to be valid per tools like this one: http://www.freeformatter.com/json-validator.html.
So, is there a limit on the size of the JSON data that can be converted by DeserializeJSON?
Thanks!
Thanks Carl.
The JSON is being submitted in its entirety, confirmed by Fiddler. And it's actually being successfully saved to a SQL Server nvarchar(MAX) field too. I can validate that saved JSON.
I'm actually grabbing the JSON to convert directly from the SQL Server, and your comments / thoughts led me down the path of resolution.
Turns out that the JSON was being truncated prior to getting to the DeserializeJSON command, but it was the cfquery pull that was doing the truncating. The fix was to
...Copy link to clipboard
Copied
Is it possible that the POST size exceeds what is set in the "Maximum size of post data" setting in CFAdmin (not likely as I think it defaults to 20MB or something like that)? Is the JSON being submitted using POST or GET (GET uses URL parameters and there is a limit to how big a GET request can be)? Or maybe the web server (IIS or Apache) is truncating the data?
Have you checked the JSON being transmitted via Developer Tools or a tool like FIddle or Charles? Is it being truncated before it even gets to ColdFusion?
-Carl V.
Copy link to clipboard
Copied
Thanks Carl.
The JSON is being submitted in its entirety, confirmed by Fiddler. And it's actually being successfully saved to a SQL Server nvarchar(MAX) field too. I can validate that saved JSON.
I'm actually grabbing the JSON to convert directly from the SQL Server, and your comments / thoughts led me down the path of resolution.
Turns out that the JSON was being truncated prior to getting to the DeserializeJSON command, but it was the cfquery pull that was doing the truncating. The fix was to enable "long text retrieval (CLOB)" for this datasource in CF Admin. I'd never run into that before or even knew that this setting existed.
Thanks again for your comments!
Copy link to clipboard
Copied
Glad you got that sorted. CLOB issues eventually bite most of us at some point.
-Carl V.
Copy link to clipboard
Copied
@Redherring917
What a rare finding: a practical application of one of the esoteric settings. Please kindly mark your response as the correct answer. It will surely help someone else in future.
@Carl Von Stetten
Say what! CLOB issues eventually byte most of us at some point!
Copy link to clipboard
Copied
@BKBK,
I see what you did there.