Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Marco Kaulea Newsgroups: comp.lang.python Subject: Re: New JSON encoding method proposal for custom objects Date: Mon, 30 Nov 2015 09:42:01 +0100 Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de pLPEqlDuQDr35gaAbOWsXwQadlVEqgeHLdeqOSDjU65A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'encoded': 0.05; 'json': 0.05; 'works.': 0.07; 'subject:method': 0.09; 'properly': 0.15; 'json,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:JSON': 0.16; 'wrote:': 0.16; 'mechanism': 0.18; 'tells': 0.18; 'load': 0.20; '2015': 0.20; 'prevent': 0.20; 'assuming': 0.22; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'message-id:@mail.gmail.com': 0.27; 'record': 0.29; 'dumps': 0.29; 'loads': 0.29; 'secondly': 0.29; 'code': 0.30; 'useful': 0.33; 'class': 0.33; 'received:google.com': 0.35; 'could': 0.35; 'instance': 0.35; 'nov': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'received:209.85.220': 0.38; 'hi,': 0.38; 'data': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'provide': 0.61; 'back': 0.62; 'necessarily': 0.63; 'goal': 0.64; 'denis': 0.84; 'movie,': 0.84; 'good,': 0.93; 'have.': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=PQX3rOEs3icMbUcOBAo5jO6QE4fLEyXt8e/3NHlkhCY=; b=slOztQApfBUXFYq/Vhahj0wM4TbEJck2mCIVbYArVJqcAaRTVJy4EZwMRYR1DC8ayo jaolKTt7YTMk91FHI6ZQrl1BAByx/3NdW866l67FZahcZrEsBAaXvCRyAsZfE4aIn0VX gNvmE/UuE4XJOd/2DgKYpRJi/LuGBBwh/BgBMrTsu+JBu5LFTcuHAAOvwmuQWxAb01Gf yxDYL53ZBaM2yDWjzT/4YeJc1RqnF15Gp5SgMDAElMcsuSOOZ0mKNDQ1lL+O39NVkUTM lfKobK7Q2UCev7EdK/BbcFryHer9B+xqWDqLVnPGl6ZkzU/GSF4IRIxCZJNNyqY4xrNN 4JrQ== X-Received: by 10.55.76.213 with SMTP id z204mr70642142qka.58.1448872941099; Mon, 30 Nov 2015 00:42:21 -0800 (PST) In-Reply-To: X-Mailman-Approved-At: Mon, 30 Nov 2015 03:56:11 -0500 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99733 Hi, I think his goal is not to load the data back into python, but to use it to provide some kind of REST-Style interface. An example would be, if you have a class instance of a record of a movie, that it could be simply encoded and send over the wire to display. Without necessarily recreating the class on the other end. This would prevent any security risks from the deserialization. On Sun, Nov 29, 2015 at 9:40 PM, Denis McMahon wrote: > 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. But I am not sure how useful that PEP/Change would be, assuming the code in Peter's response works. - Marco Kaulea