[TYPO3-dev] lib/div and creating json file

Xavier Perseguers typo3 at perseguers.ch
Tue Aug 4 14:38:57 CEST 2009


Hello Walter,

> But, when I try to send my resultList from the model through json_encode()
> every record, which holds something like 'ÄöüÜ', is NULL.
> 
> The problem is, that I don't know a method to utf-8_encode this resultList in the model. utf8_encode causes:
> 
> Catchable fatal error: Object of class tx_lib_object could not be converted to string....

You cannot expect a method taking a string argument to able to correctly 
convert an object you made as something useful. If you want it to work, 
you have to implement method __toString() in your object.

But I guess you want your object and his properties to be converted into 
a JSON array that you may then reuse with JavaScript on client side.

If so, then have a look at method encodeObjectForJSON() from 
ExtJS/Utility from extension mvc_extjs:

http://forge.typo3.org/repositories/entry/extension-mvc_extjs/trunk/Classes/ExtJS/Utility.php

-- 
Xavier Perseguers
MVC ExtJS Leader

http://forge.typo3.org/projects/show/extension-mvc_extjs




More information about the TYPO3-dev mailing list