Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!news.mixmin.net!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'json': 0.07; 'reason.': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'files.': 0.09; 'am,': 0.12; 'does,': 0.16; 'pythonic': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'etc,': 0.23; 'somehow': 0.23; 'script': 0.29; 'hi,': 0.32; 'objects': 0.32; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'conflicts': 0.34; 'keys': 0.34; 'header:X-Complaints-To:1': 0.35; 'problems': 0.36; 'two': 0.37; 'received:org': 0.38; 'url:org': 0.38; 'subject:: ': 0.39; 'suggestions': 0.39; 'header:Mime- Version:1': 0.39; 'to:addr:python.org': 0.39; 'subject: (': 0.39; 'here': 0.65; 'investigated': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Presenting recursive dict (json_diff) Date: Thu, 27 Oct 2011 15:49:47 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1319745006 news.xs4all.nl 6917 [2001:888:2000:d::a6]:36194 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15055 On 10/27/2011 4:50 AM, mcepl wrote: > Hi, > > I have here a simple script (https://gitorious.org/json_diff/mainline) > which makes a diff between two JSON files. So for JSON objects > > { > "a": 1, > "b": 2, > "son": { > "name": "Jano=C5=A1ek" > } > } > > and > > { > "a": 2, > "c": 3, > "daughter": { > "name": "Maru=C5=A1ka" > } > } > > it generates > > { > "append": { > "c": 3, > "daughter": { > "name": "Maru=C5=A1ka" > } > }, > "remove": { > "b": 2, > "son": { > "name": "Jano=C5=A1ek" > } > }, > "update": { > "a": 2 > } > } > > (obvious problems with name conflicts between internal keys and the > investigated keys will be somehow addressed later; any simple Pythonic > suggestions how?) Use '_append', etc, much like namedtuple does, for the same reason. --=20 Terry Jan Reedy