An additional option to allow the the non-encoding of python tuples #6

Closed
wants to merge 10 commits into
from

Conversation

Projects
None yet
2 participants
@Singletoned

I added an option to the JSONEncoder to allow tuples to not be automatically encoded to arrays, for the use case when you need to preserve the difference between tuples and lists (in this case you can now encode tuples to a custom object using the default() method).

I added a basic test (tests/test_tuple.py) and checked that all the other tests ran.

Unfortunately I couldn't add it into the _speedups.c, so I addd a check to iterencode that if this option has been changed, it shouldn't use the speedups.

Yours

Ed

@etrepum

This comment has been minimized.

Show comment
Hide comment
@etrepum

etrepum Sep 4, 2011

Member

This looks like a good idea, but I think I will do the implementation differently. Also, unittest.skipUnless wasn't added until Python 2.7 so you can't skip the test that way.

Member

etrepum commented Sep 4, 2011

This looks like a good idea, but I think I will do the implementation differently. Also, unittest.skipUnless wasn't added until Python 2.7 so you can't skip the test that way.

@etrepum

This comment has been minimized.

Show comment
Hide comment
@etrepum

etrepum Sep 4, 2011

Member

Actually, I don't think that being able to remove tuple from the array encoding is very useful... but encoding namedtuple as an object seems like the right thing to do. To support people who depended on the old behavior, there should also be a flag to turn this off.

Member

etrepum commented Sep 4, 2011

Actually, I don't think that being able to remove tuple from the array encoding is very useful... but encoding namedtuple as an object seems like the right thing to do. To support people who depended on the old behavior, there should also be a flag to turn this off.

@etrepum

This comment has been minimized.

Show comment
Hide comment
@etrepum

etrepum Sep 4, 2011

Member
Member

etrepum commented Sep 4, 2011

@etrepum etrepum closed this Sep 4, 2011

jperkin pushed a commit to joyent/pkgsrc-legacy that referenced this pull request Dec 9, 2013

wiz
Update to 2.2.1:
Version 2.2.1 released 2011-09-06

* Fix MANIFEST.in issue when building a sdist from a sdist.
  simplejson/simplejson#16

Version 2.2.0 released 2011-09-04

* Remove setuptools requirement, reverted to pure distutils
* use_decimal default for encoding (dump, dumps, JSONEncoder) is now True
* tuple encoding as JSON objects can be turned off with new
  tuple_as_array=False option.
  simplejson/simplejson#6
* namedtuple (or other tuple subclasses with _asdict methods) are now
  encoded as JSON objects rather than arrays by default. Can be disabled
  and treated as a tuple with the new namedtuple_as_object=False option.
  simplejson/simplejson#6
* JSONDecodeError is now raised instead of ValueError when a document
  ends with an opening quote and the C speedups are in use.
  simplejson/simplejson#15
* Updated documentation with information about JSONDecodeError
* Force unicode linebreak characters to be escaped (U+2028 and U+2029)
  http://timelessrepo.com/json-isnt-a-javascript-subset
* Moved documentation from a git submodule to
  http://simplejson.readthedocs.org/

Version 2.1.6 released 2011-05-08

* Prevent segfaults with deeply nested JSON documents
  simplejson/simplejson#11
* Fix compatibility with Python 2.5
  simplejson/simplejson#5

Version 2.1.5 released 2011-04-17

* Built sdist tarball with setuptools_git installed. Argh.

Version 2.1.4 released 2011-04-17

* Does not try to build the extension when using PyPy
* Trailing whitespace after commas no longer emitted when indent is used
* Migrated to github http://github.com/simplejson/simplejson

jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 11, 2014

wiz
Update to 2.2.1:
Version 2.2.1 released 2011-09-06

* Fix MANIFEST.in issue when building a sdist from a sdist.
  simplejson/simplejson#16

Version 2.2.0 released 2011-09-04

* Remove setuptools requirement, reverted to pure distutils
* use_decimal default for encoding (dump, dumps, JSONEncoder) is now True
* tuple encoding as JSON objects can be turned off with new
  tuple_as_array=False option.
  simplejson/simplejson#6
* namedtuple (or other tuple subclasses with _asdict methods) are now
  encoded as JSON objects rather than arrays by default. Can be disabled
  and treated as a tuple with the new namedtuple_as_object=False option.
  simplejson/simplejson#6
* JSONDecodeError is now raised instead of ValueError when a document
  ends with an opening quote and the C speedups are in use.
  simplejson/simplejson#15
* Updated documentation with information about JSONDecodeError
* Force unicode linebreak characters to be escaped (U+2028 and U+2029)
  http://timelessrepo.com/json-isnt-a-javascript-subset
* Moved documentation from a git submodule to
  http://simplejson.readthedocs.org/

Version 2.1.6 released 2011-05-08

* Prevent segfaults with deeply nested JSON documents
  simplejson/simplejson#11
* Fix compatibility with Python 2.5
  simplejson/simplejson#5

Version 2.1.5 released 2011-04-17

* Built sdist tarball with setuptools_git installed. Argh.

Version 2.1.4 released 2011-04-17

* Does not try to build the extension when using PyPy
* Trailing whitespace after commas no longer emitted when indent is used
* Migrated to github http://github.com/simplejson/simplejson

@pyup-bot pyup-bot referenced this pull request in knowsis/pyknowsis Oct 27, 2016

Open

Initial Update #1

@pyup-bot pyup-bot referenced this pull request in Sanji-IO/sanji Nov 30, 2016

Merged

Initial Update #82

@pyup-bot pyup-bot referenced this pull request in springermac/pyinstaller Aug 16, 2017

Closed

Pin simplejson to latest version 3.11.1 #12

@pyup-bot pyup-bot referenced this pull request in heavenshell/py-doco Dec 31, 2017

Merged

Initial Update #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment