Presenting recursive dict (json_diff)

Terry Reedy tjreedy at udel.edu
Thu Oct 27 15:49:47 EDT 2011


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šek"
> }
> }
>> and
>> {
> "a": 2,
> "c": 3,
> "daughter": {
> "name": "Maruška"
> }
> }
>> it generates
>> {
> "append": {
> "c": 3,
> "daughter": {
> "name": "Maruška"
> }
> },
> "remove": {
> "b": 2,
> "son": {
> "name": "Janošek"
> }
> },
> "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.
-- 
Terry Jan Reedy


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /