Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObject to JSON format

Go to End

5 Posts   6096 Views


Community Member, 57 Posts

3 June 2010 at 4:28pm

hi guys,

i read in one of old topic to create json from dataobject is with this function :
$f = new JSONDataFormatter();
return $f->convertDataObject($myDataObject);

but it's not working, it gave me this error :
[User Error] Uncaught Exception: Object->__call(): the method 'inheriteddatabasefields' does not exist on 'DataObjectSet'

Please someone tell me the correct way to create json format from DataObject


Forum Moderator, 5523 Posts

3 June 2010 at 10:08pm

Hmm can you post your full code and the full backtrace of the error. Seems a bit weird that a method is being called on a 'DataObjectSet' if your performing a function on dataobject.


Community Member, 57 Posts

4 June 2010 at 3:23am

$data = DataObject::get("TABLE","WHERE");
$f = new JSONDataFormatter();
return $f->convertDataObject($data);

It seem like the problem is the JSONDataFormatter is only work for single dataobject, if i select the dataobject using get_one or get_by_id it's working, but what i want to achieve is to hv more than one data as JSON.

Is there anything i can do?


Community Member, 253 Posts

2 October 2010 at 3:06am

Just for anyone that stumbles across this and wants the answer.

You have to use convertDataObjectSet($dos) on a dataobjectset. convertDataObject is just for a single DataObject.


Community Member, 32 Posts

14 December 2010 at 8:49am

Thanks for your help! I can now pass a JSON object to the flash.swf, really handy.

But a problem still exists: only displays with the variables from the TextFeldangabe table when I'm logged in the backend. Would there be a possibility to log in a readonly user automatically in the controller or something like that??

class TextFeldPage_Controller extends Page_Controller {

           public function jsonausgabe() {
           $data1 = DataObject::get("TextFeldangabe","TextFeldangabe.Titel='$this->URLSegment'");
           $f1 = new JSONDataFormatter();
           return $f1->convertDataObjectSet($data1);


Thanks for your help mates!!!

Please answer to thread