Why not do this with client side javascript?
data['table']['count'] = data['count'];
On Thursday, March 28, 2013 9:11:59 AM UTC-7, Rocco wrote:
>
>
> Hello,
>
> I'm doing some exciting test using jqplot and handsontable with web2py.
> The approach is almost linear:
> controller with db(...).select(...).as_list() -> @service.json ->
> $.getJSON
>
> But I've a problem using a count field, that produce a JSON output with a
> _extra field:
>
> Controller:
> @service.json
> def json_test:
> count=db.table.id.count()
> dati=db(table.afield==4).select(f_lunghezza,count,groupby(f_lunghezza
> )).as_list()
> return dict(data=dati)
>
>
>
> So if I open controller/json_test.json I get:
> {"data": [{"_extra": {"COUNT(*)": 2}, "table": {"f_lunghezza": 9.5}},...}
>
>
> qjplot has some problem with this kind of json format, so I had to use
> (client side) a js parser...
>
> ...
> $.each(data, function(index, value) {
> ticks.push(value['table']['f_lunghezza']);
> point.push(value['_extra']['COUNT(*)']);
> });
> ...
>
>
> I'm looking for a (better) way to get, instead, the following json:
> {"data": [{"table": {"f_lunghezza": 9.5,"count":2}},...}
>
>
> There is a way?
>
>
> Thanks to all
>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.