Try this (works in 1.2): First, put all of your data into a variable, for instance if your model is called items:
$items = $this->Item->findAll(); $timestamp = 1193692111; // put your timestamp here $itemArray = Set::extract($items, '{n}.Item'); $this->set('items','{"timestamp":'. $timestamp.',"items":'.json_encode($itemArray).'}'); Note - I haven't tested this, but it's modified from code I use for ExtJS. I blogged about it here: http://www.ntatd.org/mark/?p=29 (shameless plug). Make sure to check the value of items as sent to your view to make sure all the [ and ] are in the right place. hydra12 On Dec 10, 3:41 am, kchopein <[EMAIL PROTECTED]> wrote: > Hi!! > > First of all, thanks for the work! > > I'm trying to use the JSON component with the Dojo Toolkit but I'm > having a problem: the generated json code includes the model level, > and I only need the data. I mean, I'm getting this: > > {"timestamp":1193692111, "items":[ > {"Post":{"id":"1","title":"The title","body":"This is the post > body.","created":"2007-11-07 00:44:54"}}, > {"Post":{"id":"2","title":"A title once again","body":"And the post > body follows.","created":"2007-11-07 00:45:15"}}, > {"Post":{"id":"3","title":"Title strikes back","body":"This is really > exciting! Not.","created":"2007-11-07 00:45:44"}}, > {"Post": > {"id":"4","title":"aaaaaa","body":"aaaaaadadasdas","created":"2007-11-12 > 10:00:45"}} > ]} > > but I need something like this: > > {"timestamp":1193692111, "items":[ > {"id":"1","title":"The title","body":"This > is ...","created":"2007-11-07 00:44:54"}, > {"id":"2","title":"A title once > again","body":"And ...","created":"2007-11-07 00:45:15"} > ]} > > Since I'm a Cake newbe I don't know if there's a way to do this or if > I have to do it myself. How do you solve this? > > Thanks in advance!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---