Re: [Json] Another problematic JSON Schema use-case

Andrew Newton <andy@hxr.us> Thu, 26 May 2016 07:00 UTC

Return-Path: <andy@hxr.us>
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 05B0212D883 for <json@ietfa.amsl.com>; Thu, 26 May 2016 00:00:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.6
X-Spam-Level:
X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, 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=hxr-us.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 Wg4tDNlS-768 for <json@ietfa.amsl.com>; Thu, 26 May 2016 00:00:29 -0700 (PDT)
Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (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 E392D12D89A for <json@ietf.org>; Thu, 26 May 2016 00:00:28 -0700 (PDT)
Received: by mail-wm0-x236.google.com with SMTP id n129so87176020wmn.1 for <json@ietf.org>; Thu, 26 May 2016 00:00:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hxr-us.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=U69KfIZoydGy6n16t10rktQam6TOKBDtB2lWTOOQQ4Y=; b=LBbbhhC48zYelRUvLXNXqnInjKHe1ElMjhxvUjIdqPn1Kt9oYVRmDa8+FX4YrLZ/j5 ht+7fYlTgH0in2lU5ec8xKdVcLnpTEaf5Rn87m9qndlUNy3wGbFS7gEFOaepVmAQTwqE hXZM4lgdZr0cCRmTkf0G5um1FtMJAphxHL8nBu9hzTLfkzjE4T+PZ1EjCaldvCh/CTy/ omq3DO7ypPKLFt9vfUeSX30VBgj4Z+feDHUZsRAy2awgBoNubgo6vwSD5LQ3g/dmnsvE cpNSIDPCBqFC3d9eDKjRXF6f3EsTMvYsFsQ6O9/rHYUp0TKUVxOfGiK7lfGin/hh/w0o 1H+w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=U69KfIZoydGy6n16t10rktQam6TOKBDtB2lWTOOQQ4Y=; b=CxChU36vGUX7VEn7rjvlVgNvEFoWdra+gekUjNeYxWp3u1IZea49Qc1TZvOLAYQrbF uzTNm6cI0NMRilTSnOFuLnnjZnBnHDpKUQFREz7+/Qr02IdTiUZdEmENsEqVCujL5xvk 1XQFqsmYIyCfYzFUJ5Ag1ZdduuSPd3rNu3qzdHnoqrt7OwURNffXAZBQgbLz459f+rpN bs4hYjT1ohViDDxZJm1edhnLCF++blrU3oQrc/PYn5i7FA1767z6lUOyBu+oWO13joqU 7I2LoZvlKg0aKhx/B03WufbQHMAAU+Zn9U4iXY1NbMyPUzzKsUs6FuLA6cztYx3wc8xs 3ISg==
X-Gm-Message-State: ALyK8tLaLhXF60nDvhs73hh28FF2A9kJo429pLOOcSJxNSVomiFPbIBsxjU3gdqc1/uae8U4jmOohnZkBsQgYA==
MIME-Version: 1.0
X-Received: by 10.28.92.20 with SMTP id q20mr1948531wmb.76.1464246027298; Thu, 26 May 2016 00:00:27 -0700 (PDT)
Received: by 10.194.153.39 with HTTP; Thu, 26 May 2016 00:00:27 -0700 (PDT)
X-Originating-IP: [94.127.55.205]
In-Reply-To: <5745EE5E.5050801@tzi.org>
References: <CAHBU6ivd5JJ7Hx_JtNPSnW40jXzEF1Yr7=rwuZzGnFrRoMphbg@mail.gmail.com> <CANkuk-WppF4WgeZc5OX2-tozmCd+eYtPwFgmDtoiJHxwdSjDzw@mail.gmail.com> <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com> <CAAQiQRdu2pixrXhuqqmWGjdab6_mCMVcPTKWQQu=Oh0n3MmW0g@mail.gmail.com> <5745EE5E.5050801@tzi.org>
Date: Thu, 26 May 2016 09:00:27 +0200
Message-ID: <CAAQiQRcgKe=V1rmgZnMdQLdJEiftKP1fvbQRG15_AfdAVxqh1A@mail.gmail.com>
From: Andrew Newton <andy@hxr.us>
To: Carsten Bormann <cabo@tzi.org>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/FSwFgbd3rL1HIHkdBBA5-4l4Z9U>
Cc: "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Another problematic JSON Schema use-case
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: Thu, 26 May 2016 07:00:31 -0000

On Wed, May 25, 2016 at 8:26 PM, Carsten Bormann <cabo@tzi.org> wrote:
> Andrew Newton wrote:
>> It's not too much to ask, but the problem may be with the JSON parser.
>> Many parsers ingest JSON and give back native data structures, which
>> is what makes JSON simple for most people. But a validator needs
>> context that a typical JSON parser does not provide.
>
> Can you give an example for that?
>

Given the following:

[
  { "foo" : "bar" }
]

Here is what happens if I use the built-in Ruby parser:

irb(main):017:0> s
=> "\n[\n  { \"foo\":\"bar\"}\n]\n"
irb(main):018:0> JSON.parse s
=> [{"foo"=>"bar"}]

If a validator wants to ensure that "foo" is "baz" and not "bar", its
lost the information to tell the user to look at line 2.

By contrast, if a validator were to use Jackson as a stream parser, it
would have access to JsonLocation:
http://fasterxml.github.io/jackson-core/javadoc/2.1.0/com/fasterxml/jackson/core/JsonLocation.html

> (I'm familiar with a problem like this from CBOR, where CDDL maybe
> sometimes wants to make serialization choices*), which are no longer
> visible at the data model level; I just haven't seen the need with JSON.)

I'm not sure we are talking about the same thing.

-andy