Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99735

Re: New JSON encoding method proposal for custom objects

Newsgroups comp.lang.python
Date 2015-11-30 04:35 -0800
References <aac1b6e8-e294-4916-9485-ffc031c3aeb3@googlegroups.com> <n3fnru$5sf$3@dont-email.me> <mailman.32.1448873773.14615.python-list@python.org>
Message-ID <6f5cd8a5-6e14-4069-8dfe-4a1a00c05827@googlegroups.com> (permalink)
Subject Re: New JSON encoding method proposal for custom objects
From cescus92@gmail.com

Show all headers | View raw



Hello everyone and thank you for your interest!

The Peter's code is very similar to what I think the default JSON encoder should be.

The advantage of the method that I propose is that you should not care anymore about which encoder you're going to use even in case of different class instances. Imagine if you could just do

  json.dumps({[1,2,3], Obj(), [DifferentObj()] })

Probably it doesn't worth a PEP but it's a very small change that can be great for making painless REST interfaces as Marco underlined (it was exactly what I was meaning, thanks)!

Denis, the way back is not considered in my proposal. But using the standard json.loads() could be nice enough! :)

> Go to python-ideas for a lengthy discussion ;)
Where can I find it?

Thank you again, I hope now my idea is clearer!

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

New JSON encoding method proposal for custom objects cescus92@gmail.com - 2015-11-29 07:05 -0800
  Re: New JSON encoding method proposal for custom objects Peter Otten <__peter__@web.de> - 2015-11-29 16:46 +0100
  Re: New JSON encoding method proposal for custom objects Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-29 20:40 +0000
    Re: New JSON encoding method proposal for custom objects Marco Kaulea <marco.kaulea@gmail.com> - 2015-11-30 09:42 +0100
      Re: New JSON encoding method proposal for custom objects cescus92@gmail.com - 2015-11-30 04:35 -0800
        Re: New JSON encoding method proposal for custom objects Burak Arslan <burak.arslan@arskom.com.tr> - 2015-12-01 13:20 +0200
          Re: New JSON encoding method proposal for custom objects cescus92@gmail.com - 2015-12-01 04:08 -0800
        Re: New JSON encoding method proposal for custom objects Peter Otten <__peter__@web.de> - 2015-12-01 13:17 +0100
          Re: New JSON encoding method proposal for custom objects cescus92@gmail.com - 2015-12-01 04:24 -0800

csiph-web