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


Groups > comp.lang.python > #99699

Re: New JSON encoding method proposal for custom objects

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: New JSON encoding method proposal for custom objects
Date 2015-11-29 20:40 +0000
Organization A noiseless patient Spider
Message-ID <n3fnru$5sf$3@dont-email.me> (permalink)
References <aac1b6e8-e294-4916-9485-ffc031c3aeb3@googlegroups.com>

Show all headers | View raw


On Sun, 29 Nov 2015 07:05:30 -0800, cescus92 wrote:

> In this day I stumbled upon a very simple task: I had a list of
> instances of a custom class and I had to convert i into a JSON.

That's all well and good, but firstly you need to both dumps and loads to 
work properly with json, and secondly there's no mechanism in json that 
tells you what class of object you have.

So you may have a __json_dumps__ that will dump your object out to a json 
string representation, but then how does json.loads recognise that it's 
loading your object to call your object's __json_loads__?

-- 
Denis McMahon, denismfmcmahon@gmail.com

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