10389 Posts in 2200 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2513 Views |
-
DataObject to JSON format

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
-
Re: DataObject to JSON format

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.
-
Re: DataObject to JSON format

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?
-
Re: DataObject to JSON format

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.
-
Re: DataObject to JSON format

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:
http://www.depot43.ch/silverflash/flashinhalte/textfelder/textfeld1/jsonausgabe 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!!!
JoNinjasPlease answer to thread http://silverstripe.org/all-other-modules/show/15161
| 2513 Views | ||
|
Page:
1
|
Go to Top |




