Skip to main content
February 21, 2014
Answered

DeserializeJSON - is there a limit on the size of the JSON data that can be converted?

  • February 21, 2014
  • 1 reply
  • 3341 views

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!

This topic has been closed for replies.
Correct answer

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!

1 reply

Carl Von Stetten
Legend
February 21, 2014

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.

Correct answer
February 21, 2014

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!

Carl Von Stetten
Legend
February 21, 2014

Glad you got that sorted.  CLOB issues eventually bite most of us at some point.

-Carl V.