Fixing JSON Data Errors After Updating to Joomla 3.6.3

joomla invalid empty params fixed

After updating to Joomla 3.6.3, some sites have become inaccessible and show the error message:

0 - Error decoding JSON data: Syntax error

This can come from 3rd party extensions, or from the core if your site has been migrated from Joomla 1.5 using various tools.

In this post I'll explain how to use a script which can help you identify the errors and how to fix them.

Note: The script has been updated to allow checking of different columns

 TL;DR:

You can find the script and a short explanation on how to use it here: https://github.com/robwent/joomla-json-db-check

The Issue

Joomla stores rules and parameters in the database in JSON format. Previously, if that data was invalid JSON it would silently fail and the site would continue working.

In the 3.6.3 update, the validation of the syntax was improved, so issues that would previously go unnoticed now result in an error page with the aforementioned error message.

Known Causes

  • JBLibrary plugin - Causes errors on the frontend of the site, fixed in version 2.1.7
  • Jupgrade - Sites migrated from Joomla 1.5 using this extension.
  • Many other 3rd party extensions and core extensions have been mentioned.

How to Fix

Sites that have been migrated using Jupgrade may have empty parameter fields set as {""} which should either be {} or {"":""} to be valid syntax. This may be the same with other 3rd party extensions added to any site.

This is the easiest issue to fix and can be done with a simple search and replace on the database.

Note: Before performing any of the following steps, you should take a backup of your database

  1. Download a copy of the script from github and upload the file json-db-check.php to the root of your site.
  2. Browsing to the file will check all params and rules columns for invalid empty values and correct them (A note will show how many records were changed).
  3. If you see a message that some records have been changed, browse to your site and check to see if the error messages have gone.
  4. If you still see errors on the site then the problem is with fields that contain information and a full check needs to be performed.

joomla invalid empty params fixed

 

If the site is fixed after the first checks, you can safely delete the file from your server and go back to normal.

If you still see errors on the site, click on the 'Check For All Invalid Values' button which will check for all fields that contain invalid data.

Performing a full check will not modify any database information, it will only report the issues so that they can be fixed manually.

The results will show something similar to the following screenshot:

joomla invalid params report

 

From the results, you can see the tables that contain rows that have issues, the number of each row that has a problem, and the contents of the params/rules field (The issues shown in the assets table I created to test, but the one shown in the menu column already existed in my Joomla 3 test site).

You can then paste the content into any JSON validator such as jsonlint.com to point out the specific error and test a fix.

Note: If you see that the issue is related to a certain 3rd party extension, it can only be fixed if the developers know about the problem.
If you send them a mail, they may get a fix out so that other people do not run into the same problems.