CFML/ColdFusion · ColdBox

ColdBox error: Invalid JSON & The document you are trying to decode is not in valid JSON format

Upon migrating from ColdBox 2.52 over to ColdBox 2.6 I was caught out by a subtle but show stopping issue. Unfortunately the error thrown is not very precise as to the details of the error is or what exactly has triggered it.

Invalid JSON
Invalid JSON

Looking into the pages being called prior to the error you can see the line ..

Called from \coldbox\system\plugins\XMLParser.cfc: line 1013

So one can assume it is probably an issue with one of the XML file, yet which file is not mentioned. However the XML file itself is not the problem, rather it is the data contained within. As JSON or JavaScript Object Notion like XML is another form of human readable data interchange. Unlike XML though JSON is light weight and less complex.

Now if you read the official What’s New Guide for ColdBox 2.6 you can find the following heading ‘JSON notation for dynamic complex settings’.

The configuration file allowed for simple notation to create structures: {name:’luis’,active:’true’} and arrays: [1,2,3]. However, with the inclusion of the new json plugin, you can now declare full JSON syntax notations on ALL complex variables in the configuration file. So you can inflate queries, nested arrays, structures and so much more.

My slipup was that I was transferring an old ColdBox 2.52 coldbox.xml file for use in ColdBox 2.6. I had missed one of my Settings elements under YourSettings that used complex but invalid JSON style data structures. But it was easily fixed with a few single quotes here and there…

2.52 statement

<Setting name="TransferSettings"

2.6 updated statement

<Setting name="TransferSettings"

One thought on “ColdBox error: Invalid JSON & The document you are trying to decode is not in valid JSON format

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s