ppazos / yupp

Automatically exported from code.google.com/p/yupp
0 stars 0 forks source link

Soportar arrays de PersistentObjects en JSONPO::toJSON #125

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Como la serialización a XML soporta arrays, lo mismo para JSON.

Original issue reported on code.google.com by pablo.swp@gmail.com on 2 Jan 2012 at 1:26

GoogleCodeExporter commented 8 years ago
Puede ser algo así:

     $json = "";
     foreach($comentarios as $comentario)
     {
          $json .= JSONPO::toJSON( $comentario ) . ", ";
     }

     $json = substr($json, 0, -2);
     return '{"comentarios":['. $json .']}';

o así:

     $json = '['; 
     foreach ($modules as $module)
     {
          $json .= JSONPO::toJSON( $module ) .', ';
     }

     $json = substr($json, 0, -2);
     $json .= ']';

Original comment by pablo.swp@gmail.com on 2 Jan 2012 at 1:31

GoogleCodeExporter commented 8 years ago
Aparte de armar el array json es necesario hacer el loopDetection.

Puedo reusar el código de toJSON para procesar hasMany.

Original comment by pablo.swp@gmail.com on 8 Apr 2012 at 9:43

GoogleCodeExporter commented 8 years ago
Hecho.

Original comment by pablo.swp@gmail.com on 8 Apr 2012 at 6:52