Bson.errors.InvalidDocument: cannot encode object: True

I got an error while inserting a document in Mongo using python.

document = {u'Status': 'Active', u'Installation': {u'IsFrugal': True, u'IsFeatureSet': True, u'IsEvolving': True, u'IsAffordable': True}, u'AutoList': [u'IsFeatureSet', u'IsAffordable', u'IsFrugal'] } 

Error TraceBack

 C:\Python27\lib\site-packages\pymongo-2.5.1_-py2.7-win32.egg\pymongo\collection. py:357: RuntimeWarning: couldn't encode - reloading python modules and trying ag ain. if you see this without getting an InvalidDocument exception please see htt p://api.mongodb.org/python/current/faq.html#does-pymongo-work-with-mod-wsgi continue_on_error, self.__uuid_subtype), safe) Traceback (most recent call last): File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "C:\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals File "D:\Office_Drive\RetailReco\contactsnew\rrpython\rcauto.py", line 28, in <module> rceval.AutoProcess() File "C:\Python27\lib\site-packages\rrpython-0.1-py2.7.egg\rrpython\automizati on.py", line 67, in AutoProcess self._configdb[RCEVALPMTS].save(tempdict) File "C:\Python27\lib\site-packages\pymongo-2.5.1_-py2.7-win32.egg\pymongo\col lection.py", line 266, in save return self.insert(to_save, manipulate, safe, check_keys, **kwargs) File "C:\Python27\lib\site-packages\pymongo-2.5.1_-py2.7-win32.egg\pymongo\col lection.py", line 357, in insert continue_on_error, self.__uuid_subtype), safe) bson.errors.InvalidDocument: Cannot encode object: True "bson.errors.InvalidDocument: Cannot encode object: True" 

when I use a β€œtrue” instance of True, it works well, but it will insert a string value. I want to add a boolean, not a string.

when I try to insert a simple {"name": True} it works well, how is this possible? What happens if someone can give a decision, most of them are welcome.

+7
python pymongo
source share

No one has answered this question yet.

See related questions:

1623
Determine the type of object?
3
Error pymongo: bson.errors.InvalidBSON: codec 'utf8' cannot decode byte 0xa1 at position 25: invalid start byte
3
Ipython has different sys.path than python and doesn't use PYTHONPATH?
2
ImportError: no module named grappellidjango.contrib
one
Error loading dll when using python imagebot
0
Cannot classify image using label_image [Tensorflow] script
0
Error using queries in Python2.7
0
ImportError: Error loading DLL: the operating system cannot start% 1
0
python stops working suddenly

All Articles