[Json] JSON Patch and null arrays

Ron Alleva <ronallevatech@gmail.com> Thu, 05 December 2019 23:22 UTC

Return-Path: <ronallevatech@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 193CE1201A3 for <json@ietfa.amsl.com>; Thu, 5 Dec 2019 15:22:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.998
X-Spam-Level:
X-Spam-Status: No, score=-1.998 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_NONE=-0.0001, SPF_HELO_NONE=0.001, 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 4mdqAzp7y81J for <json@ietfa.amsl.com>; Thu, 5 Dec 2019 15:22:38 -0800 (PST)
Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 18A4212020A for <json@ietf.org>; Thu, 5 Dec 2019 15:22:38 -0800 (PST)
Received: by mail-ed1-x533.google.com with SMTP id cy15so4239886edb.4 for <json@ietf.org>; Thu, 05 Dec 2019 15:22:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=jVT77nlMMyFCF1RRbdXx+yL2M0+WyG4SRM6sN6OZ2OU=; b=eNW8xPpUGNyxiM8Z2EzYX5gRn/OJUpnA9F5ioPJIsL9j5o1BKrjH3BciSXgkwPbP73 nyxw2DDFR6g8TtZAqEjxZUbsouAP5OrJxviO7O08Zakws7JQkKsWyDH2ELWjov42o/go DqQLIz78b6xJd1a6cswiPASBomfSqbaRzReniKAOiNlrdqCBOpj+I/uG13B0xiaVOHdC KkQGx6E7xSwJzu3YWklQ+LlB7JR5t5eF+QTSYeRlXslyl4GTiGPLVBullE3/8P4ZIuXv sbJsxJaClyHkduSWvxirjX2r3G0Xjl+Lowm2FmzMxUc+6ElU37MHNF2HN6LJxv/SZrBZ vnxA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=jVT77nlMMyFCF1RRbdXx+yL2M0+WyG4SRM6sN6OZ2OU=; b=oP3+E/O/tozpdgm6Fpn7eQB9XNGt4Z2EbTPrZNvyq3gf+ncWSiyi+fio+uZ6sAMQWF Y3aqtOoou/JR93FnY7zP7J+yhGB7ZDTdMB0eviNhksmcEZROm/XTBkY4VsAjX8CMPM0N rXqb29vURT3LAS3KDJcJw2Y65D4Uz3ugKyZe511XiWOs3rnCfD7yANfwUUeKQmXnhuP7 2pS9KYP1muwstAqa4QFQ72Vl82vWnrckhXex5RHNfM3hmhZC+cS0xERnoy2lcjDD9YbZ 8dmDc+V1QGxQNXTi+sAOGYD5QQrnuwVNI9KVTktKpVC+8hjWDNS0h+cWBZVgx1aMGdVA wohA==
X-Gm-Message-State: APjAAAXHJQGWu/DdMZ41Lzo+F0FSB7cgZAN/wX14+nUyXg/SSxdNKRKW sKWHBmEtaDNrTOh4Ka4BlAwObOPtCvHFGzblYZtO4w==
X-Google-Smtp-Source: APXvYqx+EAFAXkdwfFtBVca4P+V67h+DHZoSYPpuHOs9Jqhn31I2Bfrk/Itxybaq4gOjDYV8O/AFlE6w0PU0UM81aFg=
X-Received: by 2002:a50:e68c:: with SMTP id z12mr13850521edm.53.1575588156261; Thu, 05 Dec 2019 15:22:36 -0800 (PST)
MIME-Version: 1.0
From: Ron Alleva <ronallevatech@gmail.com>
Date: Thu, 05 Dec 2019 18:22:26 -0500
Message-ID: <CAEwFaXL-Bd54UyBnazm_9W96WOXZpkQLqjccudJ=8mtAH69yeg@mail.gmail.com>
To: json@ietf.org
Content-Type: multipart/alternative; boundary="0000000000005dc9a10598fd34bd"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/PAgqBIoVTZ9L1yV3pzw7cGD4kXQ>
Subject: [Json] JSON Patch and null arrays
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: Thu, 05 Dec 2019 23:22:41 -0000

Hi all,

I’ve been trying to find a good answer around the internet, but I’ve come
up short. To describe the question in a JSON patch test, I’m wondering if
this should be a valid test:

{ "comment": "Add array element to null",
"doc": {"foo": 1},
"patch": [{"op": "add", "path": “/bar/-", "value": 1}],
"expected": {"foo": 1, "bar": [1]} }

What should “expected” be in this case? Some libraries seem to implement
what is above, but I’ve seen other libraries that insist you must create
the array first, and only then you can add to it, so the above would result
in an error.

The most “user friendly” approach I believe would be the above test case.
In this case, the client does not have to retrieve and interpret the object
to determine if it has to create the array first, it can just add elements.

Is there any opinion on what is a valid interpretation on the spec with
regards to this? Is it just “undefined” because we can’t know that bar is
intended to be an array?

Thanks in advanced,

Ron