Re: [Json] JSON and int64s - any change in current best practice since I-JSON

Joe Hildebrand <hildjj@cursive.net> Wed, 17 January 2024 16:28 UTC

Return-Path: <hildjj@cursive.net>
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 D3C7AC15793B for <json@ietfa.amsl.com>; Wed, 17 Jan 2024 08:28:59 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.106
X-Spam-Level:
X-Spam-Status: No, score=-2.106 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cursive.net
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uMyKnTXw94uE for <json@ietfa.amsl.com>; Wed, 17 Jan 2024 08:28:55 -0800 (PST)
Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id ED9D0C1654EF for <json@ietf.org>; Wed, 17 Jan 2024 08:28:52 -0800 (PST)
Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-5e54d40cca2so86606627b3.3 for <json@ietf.org>; Wed, 17 Jan 2024 08:28:52 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cursive.net; s=google; t=1705508931; x=1706113731; darn=ietf.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FLKn/i4pIfGXfUHifWvsOLK2UwYDlumHqf0qLu0+5sI=; b=hVwCSYxzyN0FgcfK5bXQlWy3v72X0WvOseJv5lWTcqQdu15YbzyVbPCnKLc5XJQX1S UBzCkP7ASWosVVrFebbWQQ0wBRHx9jh119bdzFTPaE8cBsE7pdRz7fiin2uakVlB0V1R 3+O1F/Pj6U0BWlPAaBhvDaiVlLTK5GPvIzoEU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705508931; x=1706113731; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FLKn/i4pIfGXfUHifWvsOLK2UwYDlumHqf0qLu0+5sI=; b=VQArdc1ULJ2YwHiq0csNiezoa9p98EPzUgvtYKNRMhaSOD8tJt0efP91CQ7Y83l5rJ C5iTSWOMh7CaT1NXyScadcNtrAJYl7A7qu4Tmwg/tQTakJZaBFWVf5NafOfvPPHS4Umt /lHj2ZQp1hiM5m9nZsGLq8uT5quOfxN59ugVo6gn+ocKGhDmzAXY8L/H+wF4Ti9hQ0Hy 2VRej/jOPKpGicVC/2waayNZjW88uBGXQP9lLcRTKBwQ8w//mfcdEZrqAJ+Pb8+1eTgZ RgEuNNwm6Wjn1Ci8pTF3k2dWSPqLqMYrZjdR6N7J+XplbmK4YlCnawrkCHb4nXaPo68g cIKQ==
X-Gm-Message-State: AOJu0YysbJ121Oh5VhByh53Gl9D6bZrg3B6EZWSN6BUmZjYCLUZ8GOOD 8Eonj+0D/2vD624W6f7breQLf4GUoWlMKiRd1NawDhT+Yg==
X-Google-Smtp-Source: AGHT+IEgXT/yaZYdVC1NpiWlqlcTSLdIR85U6eLU2uoS2HwunnZUhrpo91oCr0SOzAi+AwLws0lEvg==
X-Received: by 2002:a05:690c:3391:b0:5d7:1940:8df8 with SMTP id fl17-20020a05690c339100b005d719408df8mr6018887ywb.95.1705508931656; Wed, 17 Jan 2024 08:28:51 -0800 (PST)
Received: from smtpclient.apple (pool-71-163-33-223.washdc.fios.verizon.net. [71.163.33.223]) by smtp.gmail.com with ESMTPSA id vv25-20020a05620a563900b007832895cf8csm4632421qkn.38.2024.01.17.08.28.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2024 08:28:51 -0800 (PST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\))
From: Joe Hildebrand <hildjj@cursive.net>
In-Reply-To: <807fea1b-a22b-4d6b-aa5d-720c9b12023c@codalogic.com>
Date: Wed, 17 Jan 2024 11:28:40 -0500
Cc: "json@ietf.org" <json@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <09233A73-3A6B-4E6F-AEB8-596AC6442E24@cursive.net>
References: <87527a42-aaac-4f39-b320-05f18a2808c1@codalogic.com> <C31BF4C8-9E6C-48F8-BF7B-D2C379273B3F@tzi.org> <CAHBU6it4SaLawSiBgK9ySkbxjtHE6CX-P3r=hzcVy4ksoQo-Cg@mail.gmail.com> <CAChr6SxHfLW-A1asAndKJz-AiyJv5QP18bi=_bNdKXw7zYHThw@mail.gmail.com> <CAChr6SweYdCWxSABZ7g20Zd-xBFzcK0Ritq53S7WtjSwc-vLmw@mail.gmail.com> <E5A68370-CC2F-4618-AB39-39A382656616@cursive.net> <807fea1b-a22b-4d6b-aa5d-720c9b12023c@codalogic.com>
To: Pete Cordell <petejson@codalogic.com>
X-Mailer: Apple Mail (2.3774.300.61.1.2)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/j9mXm7MAehAaYAHGZOzvksA0ZXw>
Subject: Re: [Json] JSON and int64s - any change in current best practice since I-JSON
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.39
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, 17 Jan 2024 16:28:59 -0000

I've got something working in Peggy (https://peggyjs.org <https://peggyjs.org/>) with a couple minutes of work.  I can publish it if it's useful.

Or, start with https://github.com/peggyjs/peggy/blob/main/examples/json.pegjs and hack in whatever features you want.

The approach that seems right to me is to make it explicit; bigint's get suffixed with 'n', and there is not automatic promotion to break existing code.

Other features to include might come from:

- https://json5.org/
- jsonc (various places, just adds both kinds of JS comments)
- CBOR diagnostic notation (https://www.rfc-editor.org/rfc/rfc8949.html#diagnostic-notation)

If we were to add Date (which is absolutely the most important after bigint), I might want the other JS built-in types as well.  I wonder if we could reuse the CBOR tag registry, and make Date stringify to:

0('2024-01-17T16:26:23Z') 
or 
dt('2024-01-17T16:26:23Z')

(using draft-ietf-cbor-edn-literals)

— 
Joe Hildebrand

> On Jan 17, 2024, at 4:19 AM, Pete Cordell <petejson@codalogic.com> wrote:
> 
> On 17/01/2024 04:49, Joe Hildebrand wrote:
>> Another approach on the horizon is:
>> https://github.com/tc39/proposal-json-parse-with-source
>> Still, moving to CBOR is likely to get you much better interoperability, as mentioned in this thread.
> 
> Thanks, Joe.  That's very interesting.
> 
> It makes my wonder, does anyone know of any existing JavaScript libraries that a browser can download on the fly that can parse JSON with big numbers?
> 
> Thanks again,
> 
> Pete.
> -- 
> ---------------------------------------------------------------------
> Pete Cordell
> Codalogic Ltd
> ---------------------------------------------------------------------