[Json] JSON irritants

Tim Bray <tbray@textuality.com> Wed, 03 August 2016 05:18 UTC

Return-Path: <tbray@textuality.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 25EC012D734 for <json@ietfa.amsl.com>; Tue, 2 Aug 2016 22:18:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=textuality-com.20150623.gappssmtp.com
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 BV5FfR_uctX4 for <json@ietfa.amsl.com>; Tue, 2 Aug 2016 22:17:58 -0700 (PDT)
Received: from mail-qt0-x231.google.com (mail-qt0-x231.google.com [IPv6:2607:f8b0:400d:c0d::231]) (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 429F5128874 for <json@ietf.org>; Tue, 2 Aug 2016 22:17:58 -0700 (PDT)
Received: by mail-qt0-x231.google.com with SMTP id 52so136512292qtq.3 for <json@ietf.org>; Tue, 02 Aug 2016 22:17:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=textuality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=aQClVoGmh8ZeqpwdZxCl4NJfQ/pKL9LdcpBdyEJvhGk=; b=WdRFAkpSWftjZoHWcV3YJS3IV+ZRx3egFpXk8ylL7nRFS+23wN7TwpWFoxbHqXTIJl FqF8HKjn6Zj9GvAVy25q3wIx0ZA4cWfrZlwKR4eiTt/peinS6bVkBYCRmaW3Rzk1lYOl fShvsjZi2waQzljlHp2i0IBoPsesj+DNv4+GADbiAJQLTQzxvsjnqQ/hEDpKr1cs8nuN Jxz/C9JkSwzb7R1T5nJ4F18/+jcHCm6rfBdGcF2pwFKrOZ1SaWhwXMpPoaUdiWTn4/2x 0MDBdorixc8xjoZFK3Ljv/6ilp6DZ4awtbZe2ykb7ubVY2ON4vjI44eYiwkAZbgRMjeN HzuA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=aQClVoGmh8ZeqpwdZxCl4NJfQ/pKL9LdcpBdyEJvhGk=; b=elR8pbUFaveLEEM8Gcr8HCSQhRChgtcafHfuz5dzJ3KAJU9KEtFL8JS8/iroYn1qXk sCKJY4V3mcwd+c8LRZH3X3Kta7nHGaheaxrMj+51CGD3kJjrHhrvGbBQLgQp3RN90Jex 74KJ5nYI5C1YP7zi4Xj8Eaej9/uMIIJSNEtypJNd/1gBqx9lX1u75g15mAmGVjtUiOTT aR0EuW1kqL++mlT5BdJbCkGgQFzh21J43SpJOTkhCUK6HlPr1tUug8riX4Jr0VW4FNOA lNuE2cQ8wu6/XM4qyrjg/DmAjCXN3ZLkNNPMb6tgTGiZwVj9w0CgAEYfJzmTpuGHIiH4 0N3w==
X-Gm-Message-State: AEkoous/AvEUJQcLVRgjrJvcbfxTofBclveVSHKaeZ0/P3ttvhmxvGINWlV3Lf2gPF3yIkupnHvG/RbH3vA4sA==
X-Received: by 10.237.36.112 with SMTP id s45mr100521580qtc.7.1470201477152; Tue, 02 Aug 2016 22:17:57 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.98.212 with HTTP; Tue, 2 Aug 2016 22:17:36 -0700 (PDT)
X-Originating-IP: [24.84.248.61]
From: Tim Bray <tbray@textuality.com>
Date: Tue, 02 Aug 2016 22:17:36 -0700
Message-ID: <CAHBU6iv+S5=bxh62G+ybcgUWzQLUngVSti8X1ptENn0fA=i3ng@mail.gmail.com>
To: "json@ietf.org" <json@ietf.org>
Content-Type: multipart/alternative; boundary="001a113fecdecb675f053923f4e3"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/fz8muWmk85KlKQa5HuSfDgjAM-o>
Subject: [Json] JSON irritants
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
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: Wed, 03 Aug 2016 05:18:00 -0000

I have recently been doing an unreasonable amount of JSON work, what with
editing the drafts here, helping design AWS’s CloudWatch Events service
[1], and now working on an interesting JSON DSL that with any luck will
decloak later this year.

I have encountered the following irritants:

1. When hand-editing JSON, it is unreasonably difficult to get the commas
right.
2. When using JSON numbers, the sender *always* knows whether integers or
floats are intended, but there’s no way to communicate this information.
3. There is no timestamp literal.

Then I realized that the comma is not necessary to the grammar, it’s only
there for JavaScript compatibility.  Bah.  Anyhow, here’s the example
object from RFC7159:

   {
     "Image": {
         "Width":  800,
         "Height": 600,
         "Title":  "View from 15th Floor",
         "Thumbnail": {
             "Url":    "http://www.example.com/image/481989943",
             "Height": 125,
             "Width":  100
         },
         "Animated" : false,
         "IDs": [116, 943, 234, 38793]
       }
   }

Here’s a version with a couple more fields and the irritants removed:

  {
     "Image": {
         "Width":  i800
         "Height": i600
         "Title":  "View from 15th Floor"
         "Thumbnail": {
             "Url":    "http://www.example.com/image/481989943"
             "Height": i125
             "Width":  i100
         }
         "Location": {
             "Latitude": f49.399673
             "Longitude": f-123.508437
         }
         "Animated" : false
         "Capture Time": @2016-08-01T18:15:00Z
         "IDs": [i116 i943 i234 i38793]
       }
   }


I thought of a friendly acronym and bought a domain name and wrote an I-D
too, but I thought it might be polite and useful to test the waters here,
example first.

[1]
http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CloudWatchEventsandEventPatterns.html