Independent BSON codec for Python that doesn't depend on MongoDB.
Python
Latest commit b576657 Jan 10, 2017 @Parkayun Parkayun committed on GitHub Merge pull request #50 from xmnr/master
Fix encode_cstring integrity check
Permalink
Failed to load latest commit information.
bson Oops, typed "if" instead of "if not" Jan 10, 2017
.gitignore Added gitignore Jul 27, 2015
.travis.yml Test on Python 3.5. Jul 26, 2016
LICENSE Updated setup and license Jul 21, 2015
README.rst Added badges Jul 26, 2015
setup.py Bump version to 0.4.3 Apr 12, 2016
test.py Fixed indent Jul 26, 2015

README.rst

bson

https://badge.fury.io/py/bson.svg? https://travis-ci.org/py-bson/bson.svg?branch=master

Independent BSON codec for Python that doesn't depend on MongoDB.

Installation

~ $ python setup.py install

or can use pip

~ $ pip install bson

Quick start

>>> import bson
>>> a = bson.dumps({"A":[1,2,3,4,5,"6", u"7", {"C":u"DS"}]})
>>> b = bson.loads(a)
>>> b
{'A': [1, 2, 3, 4, 5, '6', u'7', {'C': u'DS'}]}

Sending and receiving BSON objects to and from network sockets.

>>> from gevent import monkey, socket
>>> monkey.patch_all()
>>>
>>> import bson
>>> bson.patch_socket()
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(("127.0.0.1", 12345))
>>> s.sendobj({u"message" : "hello!"})