The Joomla! Forum ™



Forum rules


Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
PostPosted: Thu Mar 22, 2012 8:56 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Mar 22, 2012 8:44 am
Posts: 2
Joomla does not support JSON properly.
Code:
$this->lessons = "[2,14,35,25,24]"; // fetched from database normally
print_r($this->lessons);
// Output: [2,14,35,25,24]
$lessons = new JRegistry;
$lessons->loadJSON($this->lessons);
$this->lessons = $lessons;

print_r($this->lessons);
// Output: JRegistry Object ( [data:protected] => stdClass Object ( ) )
echo $this->lessons;
// Output: {}


A php.net example of how it should work: @ http://php.net/manual/en/function.json-encode.php
Code:
$a = array('<foo>',"'bar'",'"baz"','&blong&', "\xc3\xa9");
echo "Normal: ",  json_encode($a), "\n";
// Output: Normal: ["<foo>","'bar'","\"baz\"","&blong&","\u00e9"]


This is probably caused by this: http://hg.joomla.org/joomla-platform/sr ... .php#cl-46
It assumes JSON is only objects {}.

Although we have access to functions like loadArray then this function does not work like json_decode/encode.
A echo output of loadArray: {"0":"[2,14,35,25,24]"}


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 8:57 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Mar 22, 2012 8:44 am
Posts: 2
Could this be moved to 2.5 bug reporting? Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 



Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group