Validating JSON
Last updated
Was this helpful?
Last updated
Was this helpful?
When the browser returns a generic error that the JSON object returned from the CFC method invalid, you can generally inspect the returned JSON information and validate it. To find the JSON that is being returned, you can use a fileWrite() method as described above or you can use the browser's debugging features to view it directly. To use the browser (assuming that you're using Chrome as the browser):
Use the "Inspect Element" to show the debuggin panel.
Click on the "Network" tab.
Run the action on the page that displays the JSON error (refresh the page, select the form options - whatever triggers the error).
In the name column of the Network debugger, you should see a reference to the CFC (e.g. "recruiters2018.cfc"). Click on the CFC name to display the output that was returned.
Many times the error will be obvious as, instead of JOSN formatted data, you will see the content of a ColdFusion error message. To make reading the error easier, you can copy the output, paste it into an HTML file, and then launch the file into a new browser window.
If the error isn't obvious (i.e. it appears to be valid JSON), copy the JSON in whole and paste it into a JSON validator like . It should immediately find the error.