Keyword

0 Error decoding JSON data: Syntax Error

More
8 years 3 months ago #160112 by Jason Landau
Replied by Jason Landau on topic 0 Error decoding JSON data: Syntax Error

Mohamed Abdelaziz wrote: Hello All,

I've found this issue while I'm editing some K2 items, after upgrading to Joomla 3.6.4
After some debugging on my personal website, I fixed this issue by hacking the file /administrator/components/com_k2/views/item/view.html.php
I replaced this statement:

FilterOutput::objectHTMLSafe($item, ENT_QUOTES, array(
			'video',
			'params',
			'plugins'
		));

With this one:
FilterOutput::objectHTMLSafe($item, ENT_QUOTES, array(
			'video',
			'params',
			'plugins',
                        'metadata'
		));

You can give it a try, may be it fix your issue.

Thank you, This resolved the issue for me as well. Joomla 3.6.5 / K2 v2.6.9

Please Log in or Create an account to join the conversation.

  • Concerto Designs Inc.
  • Concerto Designs Inc.'s Avatar
  • Offline
  • Junior Member
More
8 years 3 months ago #160129 by Concerto Designs Inc.
Replied by Concerto Designs Inc. on topic 0 Error decoding JSON data: Syntax Error
Cleaning the metadata is the only thing that worked for me - quick DIY post here:
goo.gl/vmaf80

-Alan

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 3 months ago #160138 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error
Nice one Alan.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
8 years 2 months ago #160324 by Aashir Khan
Replied by Aashir Khan on topic 0 Error decoding JSON data: Syntax Error
I tried running your query like this [note my database prefix is 'jml3_']

SELECT * FROM `jml3_k2_items` SET `metadata` = 'robots=author=' WHERE `metadata` = '{"robots":"","author":"","rights":"","xreference":""}'

but I got the following message:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET `metadata` = 'robots=author=' WHERE `metadata` = '{"robots":"","author":"","' at line 1


I tried this query as suggested by someone else on the first page of this forum:

UPDATE `jml3_k2_items` SET `metadata` = ''

This one went through but in the SQL query page, but in Joomla in K2, the error message when opening any item didn't dissapear.

Finally, I tried changing the view.html.php file as suggested by Mohamed Abdelaziz on the first page, and that did work in removing the error message in K2 and allowing me to see my items. However, I fear that perhaps I might not be able to use metadata in my K2 items anymore by carrying out his solution. So I was wondering Concerto Designs LLC if you know why I'm getting this error message in the SQL query page when running your query with the correct database prefix?

Thanks!

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago - 8 years 1 month ago #161030 by Geo Ce
Replied by Geo Ce on topic 0 Error decoding JSON data: Syntax Error
My solution:
Step 1: Edit "(JOOMLA_PATH)/libraries/vendor/joomla/registry/src/Registry.php"
Step 2:
In line 366 replace:
$obj = $handler->stringToObject($data, $options);
to
$obj_count = json_decode($data);
if(count($obj_count) > 0) {
$obj = $handler->stringToObject($data, $options);
} else {
$obj = $obj_count;
}


And everything is back to normal!
Last edit: 8 years 1 month ago by Geo Ce.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 month ago #161039 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error
Keep in mind that this is a core hack, which will be lost when you update.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #161252 by Rega
Replied by Rega on topic 0 Error decoding JSON data: Syntax Error

Geo Ce wrote: My solution:
Step 1: Edit "(JOOMLA_PATH)/libraries/vendor/joomla/registry/src/Registry.php"
Step 2:
In line 366 replace:
$obj = $handler->stringToObject($data, $options);
to
$obj_count = json_decode($data);
if(count($obj_count) > 0) {
$obj = $handler->stringToObject($data, $options);
} else {
$obj = $obj_count;
}


And everything is back to normal!


Thank you Geo Ce... it managed to overcome my problem

Thank you very much
greetings from me , I hope you succeed

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago #163801 by WinniePooh
Replied by WinniePooh on topic 0 Error decoding JSON data: Syntax Error
With K2 2.8 the error with the decoding still exists. Why does no fix has been integrated in the newest version?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 7 months ago #163830 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error
This is not directly related to K2.
Some items might have been saved or imported incorrectly.
We cannot alter existing items.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago #163880 by Arthur Johnston
Replied by Arthur Johnston on topic 0 Error decoding JSON data: Syntax Error

This is not directly related to K2.
Some items might have been saved or imported incorrectly.
We cannot alter existing items.


Using Joomla 3.75, PHP7.0 and new install of K2 v2.8, after importing Joomla Content.

When accessing the imported content results in 0 Error decoding JSON data: syntax Error.
Note: The error did not occur until after the installation of K2.

One explanation of the issue is:
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.
reference:
www.robertwent.com/blog/fixing-json-data-errors-after-updating-to-joomla-3-6-3/

Arthur Johnston
Meadowbrook Kennels
Home of SeaCrest Cockers & Meadowbrook Border Terriers
<=-Quality-Temperament-Confirmation-=>
seacrestcockers.com

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 7 months ago #163894 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error
Nice one Arthur :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
7 years 5 months ago #165070 by migors
Replied by migors on topic 0 Error decoding JSON data: Syntax Error
Hi friends, i have the similar problem. I have joomla 3.8.1 website with more than 1700 articles. I upgraded the page form joomla 2.5 to 3. Everything is working nice. I installed k2, imported articles and all works nice except in k2 admin i can not open any item the error is:
Error decoding JSON data: Syntax error

Manual editing is not an option. An deleting meta data is not an option, All articles has meta data.

I tried fix from gihub it does not helped. Core files is not an option.

what can i do?
Thanks

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 months ago #165077 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #166410 by Dustin Rocksvold
Replied by Dustin Rocksvold on topic 0 Error decoding JSON data: Syntax Error
I tried following the link to www.robertwent.com/blog/fixing-json-data-errors-after-updating-to-joomla-3-6-3/ but the github site referenced did not work.
I did a little searching on my site using phpoMyAdmin.
I found that there were multiple articles that I could not open (throwing the error message in the post subject) that had issues with the metadata.
I used the find and replace feature of phpMyAdmin to search the metadata field and look for {"robots":"","author":"","rights":"","xreference":""},
in the replace field I added robots= author=.
Once replaced I am now able to open and edit the articles.

Hope this helps.

Dustin

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #166429 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error
Thanks Dustin :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
7 years 1 month ago #166980 by Mike
Replied by Mike on topic 0 Error decoding JSON data: Syntax Error
I have read through much of the posts on this issue and am having a hard time accepting that the problem is not with K2.

Here's why - Clean install of Joomla 3.8.5 with sample data and install only K2. The sample data has only one article. Import Joomla content into K2. Attempt to access the one article through K2 results in the error.

How can this be a Joomla problem?

Please Log in or Create an account to join the conversation.

More
7 years 1 week ago #167603 by komir
Replied by komir on topic 0 Error decoding JSON data: Syntax Error
Your solution solwing my problem.
Please, if you know, what will be correct SQL query to change all {"robots":"","author":"","rights":"","xreference":""},
to
robots= author=

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 week ago #167612 by Krikor Boghossian
Replied by Krikor Boghossian on topic 0 Error decoding JSON data: Syntax Error
Did you try this tool?
github.com/robwent/joomla-json-db-check

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
7 years 1 week ago - 7 years 1 week ago #167617 by komir
Replied by komir on topic 0 Error decoding JSON data: Syntax Error
Unfortunately its not helped
Last edit: 7 years 1 week ago by komir.

Please Log in or Create an account to join the conversation.

More
7 years 5 days ago #167633 by Mustafa Basaran
Replied by Mustafa Basaran on topic 0 Error decoding JSON data: Syntax Error
Solution for Joomla above 3.8.x:

Problem is in this case is the "registry.php" File.
Path: libraries/vendor/joomla/registry/src/Registry.php

In the "zip"-File are 2 Files.
a.) original "registry.php" File, that causes the failure on K2 items that are imported.
b.) modified "registry.php" file, that does not cause the problem.

Here The Solution.

- open the zip in attachement with 2 Files. the original and the temporarily registry.php files.
- replace the original registry.php with the temporarily registry file
- then open all the K2-Items that causes this problem, and Save (or Save and close)
- important!! at last, replace the temporarily file with the original again.
---> because while you replaced the original with the temp-file, in front-page will be an error in this K2-Item.
But with the original file again, this problem wont exist.

hope i could help.
Attachments:

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum