CF Coding Practices
  • General Coding Practices
  • Debugging JSON-based CFC Methods
    • Valid JSON Formatting
    • Validating JSON
    • Final Hints
  • How We Invoke Modals
  • Submit Handlers
  • Useful SQL Snippets
  • jQuery/JS How-Tos And Hints
  • jQuery dataTables Tricks
  • CFSCRIPT Snippets and Hints
  • StatusPage Integration
  • Windows Server Setup
  • Common CF Formatting Commands
  • CF Snippets & Hints
  • Developing With The Mura Platform
    • ContentRenderer.CFC
    • Iterators
    • Iterating Remote Feeds
    • Components
    • Nested Content and Interactive Page Assembly
    • Modules and Display Objects
Powered by GitBook
On this page

Was this helpful?

  1. Debugging JSON-based CFC Methods

Validating JSON

PreviousValid JSON FormattingNextFinal Hints

Last updated 6 years ago

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):

  1. Use the "Inspect Element" to show the debuggin panel.

  2. Click on the "Network" tab.

  3. Run the action on the page that displays the JSON error (refresh the page, select the form options - whatever triggers the error).

  4. 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.

  5. 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.

  6. 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.

JSON errors can be numerious - from column data starting with spaces, unescaped special characters, etc. so a 3rd party validator is highly recommended.

https://jsonlint.com