Re: [Json] On flat vs nested JSON encoding style

Anders Rundgren <anders.rundgren.net@gmail.com> Fri, 05 February 2016 15:10 UTC

Return-Path: <anders.rundgren.net@gmail.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C3D031B3A3E for <json@ietfa.amsl.com>; Fri, 5 Feb 2016 07:10:45 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TQWNpra9lvap for <json@ietfa.amsl.com>; Fri, 5 Feb 2016 07:10:39 -0800 (PST)
Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 89F8A1B3A37 for <json@ietf.org>; Fri, 5 Feb 2016 07:10:39 -0800 (PST)
Received: by mail-wm0-x233.google.com with SMTP id g62so52077457wme.0 for <json@ietf.org>; Fri, 05 Feb 2016 07:10:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=7LSjKb/UFa4A91ObKx9JSz7nohATFyXUo1K1dsU+NxY=; b=ItqKWJruBg3tzMwVvgo3sKUmNyI61KXllsCNnzfLuEU2QCV6ENnmKK4TsDEJn84PG+ +A7S0mYpMzyNfoHstHc9D2vUHwTOK2PIkRyQIEYwjLBpU1YrWY2E2O5LPDbc8Hr1u3+A ObunEDaiu1EAmReuhGUOI1DvtspmOa9kdwKoK1jbA5z8Khmp0xBed2EWRdfajYqZaPnH /tdN5pAvyZvgSFfM2Xzxnp4WEiBOR2Jyf/ddzCKx3JhCKkKrFKBJYvjbz+SeXGEm70g/ Pqneyl7IYFUwMy6mVRfHJrweSS9dwu0Dml95OHz9/E+ex+HCaG3XnolLIEWEqpnfy/C0 86tA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=7LSjKb/UFa4A91ObKx9JSz7nohATFyXUo1K1dsU+NxY=; b=OyzXWJvmevGylm36dLGq5EiuaikiM6bFqZrBo7HX0aDuEBs5cgpVj52Thf3ibIKZmw D/LqdQV7YZdyCSsG5WVT5+ipe5Vkx0AS2QGTLi9v/wZ7P5k+30B1JZDTJnKBqOrqnocg S13p7yyCYYv6e/1zjjY+9byNaX7WmLFevTaw0yC/6xb8RSB3hWt33T3c9XRCaA6QQntf 7rJZcqI1APhV+KKv9NjbIwKeJy8QfSzhCRkVexUsns31E/kst8IyBF4dRYNLd6P6+oLl 21QWthOsRT3koFx8sAZpp2pSgUF43Z1cTXDm0eDzZXYGnNRREjBxguZyD0JTu3L7S4/x ghDg==
X-Gm-Message-State: AG10YOSNtPItfwDxk7XeWUYKio2Ha6/11FO1Ccov7wuBnQK1jRndHzT6nBtKFB7VNaT91Q==
X-Received: by 10.194.117.169 with SMTP id kf9mr14741760wjb.122.1454685038167; Fri, 05 Feb 2016 07:10:38 -0800 (PST)
Received: from [192.168.1.79] (9.197.130.77.rev.sfr.net. [77.130.197.9]) by smtp.googlemail.com with ESMTPSA id uo9sm16285561wjc.49.2016.02.05.07.10.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Feb 2016 07:10:37 -0800 (PST)
To: Phillip Hallam-Baker <phill@hallambaker.com>, Tim Bray <tbray@textuality.com>
References: <CAMm+LwirhVcmUkdfyA3WKe_W747JTWNF1Ht2Nr8NJdDxOFCJOw@mail.gmail.com> <56B36D15.1030306@gmail.com> <56B370A1.1050508@tzi.org> <56B373B8.7040305@gmail.com> <20160205001717.GC2997@mercury.ccil.org> <CAMm+Lwg4iqKtUjX+gw2zMu6A-fRc7_MRT14R3n670gBzMtdP9Q@mail.gmail.com> <56B43FCE.6080408@gmail.com> <CAHBU6iu9peh7YkPV4SsRmtmuEjwoQH_Kg+Wf3qtvBccT=iChRQ@mail.gmail.com> <CAMm+LwhZdAC1nnO=2qqMrgDfXtjtz37cLSac3c_EvQExWoLv4w@mail.gmail.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <56B4BB58.4010104@gmail.com>
Date: Fri, 5 Feb 2016 16:10:16 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
MIME-Version: 1.0
In-Reply-To: <CAMm+LwhZdAC1nnO=2qqMrgDfXtjtz37cLSac3c_EvQExWoLv4w@mail.gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/Tp0PVV1JvEPwJ1BrpZwai8mdMFQ>
Cc: Carsten Bormann <cabo@tzi.org>, John Cowan <cowan@mercury.ccil.org>, JSON WG <json@ietf.org>
Subject: Re: [Json] On flat vs nested JSON encoding style
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 05 Feb 2016 15:10:45 -0000

On 2016-02-05 15:01, Phillip Hallam-Baker wrote:
<snip>
> What you are arguing for is that you want to write your structures like this
>
> struct fred { int a, int b, int c}
>
> { "a" : 1, "b" : 2, "type" : "fred", "c" : 3}
>
> Now you might think that is a reasonable way to present the data in a
> spec but most of us would say that it is hard to follow. The important
> information of the type of the structure is buried in the
> serialization stream.

I fully buy into the efficiency aspect of the nested encoding style (which I
honestly had never thought of), but when it comes to "hard to follow", predictable
serialization a la ES6 seems like a more universal solution since this also sucks:
   {
      "city": "Paris",
      "name": "John Doe",
      "country": "FR",
      "zip": 245333
   }

ES6 serialization and the nested encoding style scheme can easily be combined,
hopefully bringing out the best of both worlds!

Anders