try this code:

def getgraphData2():
    ret=[]
    rows=[
    {u'values':[[1411128000,u'119.989876762313']],u'key':'a'},

    ]
    for row in rows:
        print row
        for value in row['values']:
            print value
            if type(value[1]==type(u'a')):
                value[1]=round(float(value[1]),2)
            value[0]=int(value[0])*1000
            value.append(row['key'])
            ret.append(value)
    return json.dumps(ret)

if outputs this to the browser at  /default/getgraphData2

[[1411128000000, 119.98999999999999, "a"]]
and not
[[1411128000000, 119.98, "a"]]


2014-09-19 13:21 GMT+01:00 Leonel Câmara <[email protected]>:

> This is just how floats work. 0.2 is not representable in binary so you
> round it and you endup with the same float problem.
>
> That said I don't know why you're getting that problem because I can't
> reproduce it with either stdlib json or web2py's included simplejson.
>
> >>> json.dumps([[1410938640000, -0.20000000000000001, "RI_12N01_VAL"],
> [1410938700000, -0.20000000000000001, "RI_12N01_VAL"]])
> '[[1410938640000, -0.2, "RI_12N01_VAL"], [1410938700000, -0.2,
> "RI_12N01_VAL"]]'
>
>
> Show us the code!
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to