Error decoding JSON data: Syntax error

With the release of Joomla 3.6.3, some sites started to get this error message:

"Error decoding JSON data: Syntax error".

This tutorial will explain the issue and how to resolve it.


Background info

Joomla stores some of its data as JavaScript Object Notation (JSON). JSON has syntax rules that describe how the data must be stored. If the data gets corrupted and doesn't maintain the rules, an error occurs.

In version 3.6.3, the Joomla core started to report more errors if the data is stored incorrectly. Now if the JSON syntax is broken, the error is triggered and displayed. So in other words, Joomla 3.6.3 isn't causing the problem ... it's just doing a better job of reporting it.

The root cause of the error

The issue is with the data. So any fix that you find for modifying core files is incorrect. Plus, core changes will be lost when you update Joomla.

The key to fixing the issue is fixing the data itself. But where is the data? It's in the database of course. And it's usually in a "params" field in the _extensions table or _modules table.

How to fix the error

Now that we know where to look, how do we spot the issue and how do we fix it? Unfortunately, this part is tricky. Sometimes it's obvious though. The following is broken JSON:

{""}

And it can be fixed with:

 update `abc_modules` set params="" WHERE params = "{\"\"}";

Change "abc" to your table prefix. Also, run the above on your _extensions table too. To do that, switch `abc_modules` to `abc_extensions` .

The code above will fix the most common issues that have been spotted so far. But there are other syntax errors that can cause the issue. And they are usually harder to spot.

Here's one from a site I debugged earlier:

{"administrator":"\"en-GB\"","site":"\"en-GB\""}

It was in the com_languages param. I'm not sure of the cause, but it might have been due to Magic Quotes GPC being enabled at one point.

To find others, you'll have to manually look through the "params" column for potential issues.

Rob Went has released a small script that automates much of the process.

Also, if the issue is found in a 3rd-party extension, update the extension. If you don't have admin access, disable the extension via the database, then update.

Two extensions with known issues are JB Library Plugin and JUpgrade. JB Library's team has already released a fix for it.


About the author

Nick is the Director of Support at Joomlashack and you can find him in almost every area of the site, from answering support requests and account questions to creating tutorials and software.