Re: [Json] Go JSON parser ignores the case of member names

Rob Sayre <sayrer@gmail.com> Thu, 10 March 2016 02:01 UTC

Return-Path: <sayrer@gmail.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 9396F12DCE2 for <json@ietfa.amsl.com>; Wed, 9 Mar 2016 18:01:07 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.699
X-Spam-Level:
X-Spam-Status: No, score=-2.699 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 svA3_RGjzEma for <json@ietfa.amsl.com>; Wed, 9 Mar 2016 18:01:03 -0800 (PST)
Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (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 F06B812DADF for <json@ietf.org>; Wed, 9 Mar 2016 18:01:02 -0800 (PST)
Received: by mail-io0-x22d.google.com with SMTP id m184so89418016iof.1 for <json@ietf.org>; Wed, 09 Mar 2016 18:01:02 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=P7dmHkH1IAXFMBuVwTa5dPRVUetfYCIO3MeJkOyPMIE=; b=L0XX7xBh70W1vi5GXsq4YlFuyx3LQxQqqEFwUUy49nFf6mDCe5gDF0Iel3wts1x7m7 OsgfiXht0qL7W1Okih8QWmx0dI9UIlYPELTpoJ5985BS009Q3cK5oLhZ8hjZMfRSaSm4 tSK71TRI0NDPPp6RL5ZF6noNs2fPs4c4Alx1C+KDtty4KDIjHzZkQj0HHFV/p5xU2Opl 2aUC9dCvy1Fbt+YB85DPIhRDpgVbShOTmhiCi4rQtkUFdVadOlfxr86WqjpYrFMwmSo+ InYrp7l4Y7gDqykQ8chvCtbCSirTtPgcSlVWEb9KRswi9/dnMo2dmT3TjcQY4kbN5fZr hoyA==
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=P7dmHkH1IAXFMBuVwTa5dPRVUetfYCIO3MeJkOyPMIE=; b=mrNTZYoy54VZwkNUcmiA/xnmZYfk3IjEk6mKAs2cD+Jbiby4ogX4gWa0Bm7UPm0FUR AD10zaNTGrY6n8R5Q2bOlf4Oadmgunn7WUMyY5+lh0xtAV//KTcQZomwsggy6Vy4GTC9 chBIyVMDb7tmMJNraYVI2/V+LQDNOsc2jD223/bYHG6hpMlPFHgT6QplqVeRMoIbjZa/ 42yqUqmdXjspb7C5J6fNQ0VCCA1Eu6+pXJy1BRz5rRUkEZxv4uh3fLukYgESSooJ5QLr TSeCJAfDbxCdzz1W86XOa3tkR0kC0BlQIrH1jx0OyDXFPaP/Q5bd7gqIrqUEsiikW5fA LNlA==
X-Gm-Message-State: AD7BkJK3A0kdZK5QmpSL/7dXMMfyICI0X+UV+bScVz54MsiPwSF/HItAI0J/HscILZ35azBNr1s02xMU0O5Q8Q==
MIME-Version: 1.0
X-Received: by 10.107.164.170 with SMTP id d42mr965377ioj.80.1457575262101; Wed, 09 Mar 2016 18:01:02 -0800 (PST)
Received: by 10.107.20.88 with HTTP; Wed, 9 Mar 2016 18:01:02 -0800 (PST)
In-Reply-To: <20160309213830.GB9515@mercury.ccil.org>
References: <255B9BB34FB7D647A506DC292726F6E13BBE5873A1@WSMSG3153V.srv.dir.telstra.com> <20160309012028.GQ32247@mercury.ccil.org> <CAChr6SyGoRO-CgH5cPSXLLhnqkd5kJb9XpJ-evgJ1kB=mUot9A@mail.gmail.com> <20160309213830.GB9515@mercury.ccil.org>
Date: Wed, 9 Mar 2016 18:01:02 -0800
Message-ID: <CAChr6SwdCcb=xd+K4J2tbDqKSmqWjEoO8DKhb1QrtG9KEo28rw@mail.gmail.com>
From: Rob Sayre <sayrer@gmail.com>
To: John Cowan <cowan@mercury.ccil.org>
Content-Type: multipart/alternative; boundary=001a114217dcbb29b5052da82fea
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/wo8C-XHuGpL8irCgAVAOLcpohK0>
Cc: "Manger, James" <James.H.Manger@team.telstra.com>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Go JSON parser ignores the case of member names
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, 10 Mar 2016 02:01:07 -0000

On Wed, Mar 9, 2016 at 1:38 PM, John Cowan <cowan@mercury.ccil.org> wrote:

> Rob Sayre scripsit:
>
> > Well, there are ways to avoid it too (see below). I see it more as an
> > object-mapper convenience than a JSON conformance problem. I imagine
> object
> > mapping libraries in other languages have this feature too.
>
> The problem arises in cases like this: Suppose the spec says that key
> "alg" specifies the name of the algorithm, and defaults to "none" if
> there is no key.  Then if the upstream provider sends {"typ" : "JWS",
> "ALG": "HS256"}, then a receiver written in Go will see the algorithm
> as HS256, whereas any other receiver will see the algorithm as "none".
> That's almost certainly not the desired result.
>

I understand the situation. I guess I don't agree there's a conformance
problem here, since there are plenty of other APIs in the standard package
that don't do this transformation, and even the API in question doesn't do
this transformation for all arguments. They're right below the section
James quoted.

BTW, here's how to get a similar effect using the widely-used Java library
Jackson[0]:

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES,
true);

- Rob

[0] http://wiki.fasterxml.com/JacksonHome



>
> --
> John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
> To say that Bilbo's breath was taken away is no description at all.  There
> are
> no words left to express his staggerment, since Men changed the language
> that
> they learned of elves in the days when all the world was wonderful. --The
> Hobbit
>