Re: [sage-support] json and sage

2010-02-19 Thread Mike Hansen
On Fri, Feb 19, 2010 at 3:52 PM, jpc wrote: > Should one do the "type cast" below for every int or float when using > sage ? > > sage: type(float(x)) > > sage: json.dumps( {"a": float(x)} ) > '{"a": 1.8}' > > Any easier way ? You write a custom encoder to do this: http://docs.python.org/librar

[sage-support] json and sage

2010-02-19 Thread jpc
Python json library is of simple use but there's this problem: sage: import json sage: json.dumps( {"a": 1.8} ) ...produce an error because: sage: x = 1.8 sage: type(x) Should one do the "type cast" below for every int or float when using sage ? sage: type(float(x)) sage: json.dumps( {"a": flo