Re: [Json] JSON Schema Language

Austin Wright <aaa@bzfx.net> Mon, 06 May 2019 21:26 UTC

Return-Path: <aaa@bzfx.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 9DE0312002F for <json@ietfa.amsl.com>; Mon, 6 May 2019 14:26:48 -0700 (PDT)
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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=bzfx.net
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 phDZoxgxacMd for <json@ietfa.amsl.com>; Mon, 6 May 2019 14:26:46 -0700 (PDT)
Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (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 7D22E120020 for <json@ietf.org>; Mon, 6 May 2019 14:26:46 -0700 (PDT)
Received: by mail-pl1-x642.google.com with SMTP id z8so7009525pln.4 for <json@ietf.org>; Mon, 06 May 2019 14:26:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bzfx.net; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=zOx+r6jaY32yLzb1/zOW3WSCusz+Br4xg9F3MPIn3Rs=; b=qWCcjtLs4UVfhcTNEAshrRNUjohZRqNBgbT8wD65ZUyaRHHxKAHQad/hok9dM1nyZk R080Ky2Xi1dA3LYcVFSuw3VkSVLA8JQF13XfcHjAHwSWznk4RTTNw8TC8wAq9Z66Y2cn 4wzpuMTjytggLmmfLkWg4JtOCPLTLANP6AVe0=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=zOx+r6jaY32yLzb1/zOW3WSCusz+Br4xg9F3MPIn3Rs=; b=qv+T+MzXJf3t8kaiyyjLLVR/bq1a8zUf7fpRhMakUFwDczn29NiZx5sfEcUzg99erw xOhKhWvsUVI2ogcmuFscgr10ifFdEOPuOagNHSIdi0SjlnoLXgaI5ZPpzbI2zBpCjQEQ k3C71WicF7RpgsWJqMaqdUujQLMOMYJ9InqoPrIsjtjkvJI8IbvaQ+2JXCaa/LenWRk1 KHNaeAFra4fzqpcD7HGuGD5l3Ge/A1FL0zn+z+kjY7VkxBYPIB9ndShH8322IdNERJcV o0ejwD+3ultAu1AD8CGkiz/hVT5X7ZuzVLpaQsL7bgFxlKNSl4pmYtuIWEi8dL3P3a+t GWgA==
X-Gm-Message-State: APjAAAXYIV3j9GsNs7BkjTqXZ4inT0VEaB+w+Gt6NmEf4tuXa8h6XS7b n6me9kthk0WFhX7kV6Rs2kmkQQ==
X-Google-Smtp-Source: APXvYqyRNlx6WDhyVxtR+BbUYYojsGNKaCbvg4wmLaP3F6ughmVYzdh0jXVpx2IIvK1Pt7MN8Kcprg==
X-Received: by 2002:a17:902:8609:: with SMTP id f9mr33898256plo.32.1557178005763; Mon, 06 May 2019 14:26:45 -0700 (PDT)
Received: from [192.168.0.116] ([184.101.46.90]) by smtp.gmail.com with ESMTPSA id z10sm13801372pge.87.2019.05.06.14.26.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 14:26:45 -0700 (PDT)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\))
From: Austin Wright <aaa@bzfx.net>
In-Reply-To: <20190506211509.GL21049@localhost>
Date: Mon, 06 May 2019 14:26:43 -0700
Cc: Carsten Bormann <cabo@tzi.org>, json@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <32F23E7E-F3AA-4244-AAEC-4582AE7919B9@bzfx.net>
References: <AD5ABD9C-F5F2-477D-B862-529C890D5472@bzfx.net> <DA1767B8-22D6-4EA9-8112-4B36B79E9039@tzi.org> <D21B379B-23CC-48B3-BE10-D2777308E2E0@bzfx.net> <40f80ea0-d130-3f3b-39fa-2c84e802ed55@gmail.com> <35E2623E-753D-4918-8AF4-BF0BC5DE4868@bzfx.net> <6260354b-aca2-e001-7145-148b32658416@gmail.com> <9D90C1F1-6747-4373-93B0-8D51C5B25F1C@bzfx.net> <751DAC92-D70C-4C5E-9C61-954D6E300A1F@tzi.org> <20190506192453.GK21049@localhost> <753A412B-299F-400F-9D19-A9688068D842@bzfx.net> <20190506211509.GL21049@localhost>
To: Nico Williams <nico@cryptonector.com>
X-Mailer: Apple Mail (2.3445.104.8)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/3tnG_43NXryNNDneVBr_EZ_U2hM>
Subject: Re: [Json] JSON Schema Language
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.29
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: Mon, 06 May 2019 21:26:49 -0000


> On May 6, 2019, at 14:15, Nico Williams <nico@cryptonector.com> wrote:
> 
> On Mon, May 06, 2019 at 02:00:54PM -0700, Austin Wright wrote:
>>> On May 6, 2019, at 12:24, Nico Williams <nico@cryptonector.com> wrote:
>>> Because some of us have generic parsers with associated DSLs and we
>>> don't want to be left out.
>> 
>> Left out of what, exactly? See below.
> 
> Out of interoperating with other applications using this schema thing.

You’ll need to provide a specific example, I think there’s a misunderstanding.

> 
>>> [...]
>> 
>> I’m not suggesting a variance from the JSON semantics.
> 
> If you would have your parser reject 10.0 because the schema says to
> expect an integer, then you are forking JSON as you are precluding
> interoperability with some JSON encoders.  Especially too if you then
> also insisted on a fractional part when a schema element expects a real
> number so that you'd have the parser reject 10 -- then encoders would be
> damned if they do and damned if they don’t.

> 
> I explained how this would preclude use of jq or any other XSLT/XPath-
> alike for JSON from interoperating with applications using such a schema
> language.

I never suggested this. While JSON doesn’t specify what an “integer” is (i.e. we could define it to be any subset of number that we want), JSON Schema tries to be liberal and specifies that excessive precision still qualifies as an integer. (I’m the one who added that language.)

> 
>> My suggestion is an alternative to parsers that lose data when they
>> parse JSON documents, for example, ECMAScript's JSON.parse number
>> parsing. You can, of course, always parse a JSON document according to
>> the generic semantics.
> 
> The key word there is "alternative".  You're forking JSON.
> 
>> The issue here is how does a program parse a JSON document that with a
>> wider range of values than what the program has room for? Either a
>> string that’s too long, an array with too many items, or a number with
>> too many significant figures?
> 
> I explained this earlier.
> 
> First, as to fractional parts of numeric values, a) zero fractional
> parts MUST be tolerated, b) non-zero fractional parts can be truncated,
> rounded, or rejected according to the schema authors' choice.
> 
> This is a case where being liberal in what you accept is a good thing.
> 
>> Normally you would have to write your own parser, or use a tokenizer
> 
> Why not use an off-the-shelf one?
> 
>> that preserves the lexical values without casting them to native
>> types. Then you perform your own validation in code, and decide how to
>> convert a lexical JSON number into a native number, depending on
>> context.
> 
> That's one way, and it has to be possible, because that's essentially
> what you'd do with jq or ECMAScript.
> 
> You could also use a streaming parser (which jq also has) to immediately
> handle each value as it is parsed.
> 
> You could also write a combined parser and validator.
> 
> And, of course, you could generate a parser&validator from the schema.
> 
> I'm not rejecting any of those choices.
> 
> I'm insisting ONLY on the first choice (first parse, then validate)
> needing to remain valid and workable.  If you make this choice no longer
> feasible, then you've forked JSON.  Please don't.
> 
> Nico
> --