lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

integer/float dict keys are stored as strings #79

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
class Animal(Document):
   name = TextField()

2.
animals = [
        {'name': 'keiko','foo': None,  'bar':[{ 1242.34 :
[3.1415957,{'kab':'kac','kad':25}]},{'tugudu':'proutch'}] }, ...]

3.
animal = {}
for each in animals:
   print each
   animal[each['name']] = Animal()
   for key,val in each.iteritems():
     print key, val
     animal[each['name']][key] = val
   animal[each['name']].store(db)
print '*' * 80
print 'animals stored in database'
print animal

What is the expected output? 

{'foo': None,'bar': [{1242.3399999999999: [3.1415956999999999, {'kab': 
                      ^                 ^
'kac', 'kad': 25}]}, {'tugudu': 'proutch'}], 'name': 'keiko'}
What version of the product are you using? On what operating system?

What do you see instead?

'keiko': <Animal '1812442c1c0c74fb5327c4bea84df833'@'1-1996838772' {'bar':
[{'1242.3399999999999': [3.1415956999999999, {'kab': 'kac', 'kad': 25}]},
  ^                  ^      
 {'tugudu': 'proutch'}], 'name': 'keiko', 'foo': None}

Please provide any additional information below.

Original issue reported on code.google.com by t...@thomas-harding.name on 22 Jun 2009 at 8:09

GoogleCodeExporter commented 8 years ago
OK, I switched the module code to cjson instead of simplejson, and the first 
shows me
the error:

JSON encoded dicts MUST have string/utf8 string keys.

I apologize for the mess...

Original comment by t...@thomas-harding.name on 25 Jun 2009 at 9:28

GoogleCodeExporter commented 8 years ago
Yeah, simplejson is simply more tolerant about this.

Original comment by cmlenz on 29 Jun 2009 at 12:08