Re: [netmod] RFC7952 JSON streaming decoding efficiency?

"Rob Wilton (rwilton)" <rwilton@cisco.com> Thu, 28 February 2019 09:29 UTC

Return-Path: <rwilton@cisco.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6C17E130F16 for <netmod@ietfa.amsl.com>; Thu, 28 Feb 2019 01:29:15 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.501
X-Spam-Level:
X-Spam-Status: No, score=-14.501 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.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 bf0Gear1NnzN for <netmod@ietfa.amsl.com>; Thu, 28 Feb 2019 01:29:13 -0800 (PST)
Received: from alln-iport-7.cisco.com (alln-iport-7.cisco.com [173.37.142.94]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 730CF130E25 for <netmod@ietf.org>; Thu, 28 Feb 2019 01:29:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1926; q=dns/txt; s=iport; t=1551346153; x=1552555753; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=W12yq7mZ5NQ1SkGA1MfTBm6EhmX4huc+/ZCMSZjtfHM=; b=fCOtOivKdV4u5PvkdiCgPEOh12qtkHC8KKFQA4bGkKSayQeWux6m+7x4 bQs6TyxXT/klclmYOjxBEm68NT9xCxWVxfE8NtEuewK2EHqPQNEYv2X6G doInzUt2EDceh5mFjOEzR6GkxSt1mcECrUurUZp0Ue6BcKWCcwaLKMk/q U=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0AEAAA5qXdc/4MNJK1kGgEBAQEBAgEBAQEHAgEBAQGBUQUBAQEBCwGBWiqBaycKg36IGotNgg2YIIF7CwEBhGwCF4N5IjQJDQEDAQEDAQMCbSiFSgEBAQQjBA1RBAIBCA4DBAEBAwImAgICMBUICAIEARIIgk+CPKwQfDOKK4ELhHCGTReBQD+BEYMSgUGGSoJXAooWgiaXLgkChnuLZSGTHIpdkhcCERSBKB84gVZwFTuCbJBdQTGRLYEfAQE
X-IronPort-AV: E=Sophos;i="5.58,422,1544486400"; d="scan'208";a="240686693"
Received: from alln-core-1.cisco.com ([173.36.13.131]) by alln-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 09:29:12 +0000
Received: from XCH-ALN-008.cisco.com (xch-aln-008.cisco.com [173.36.7.18]) by alln-core-1.cisco.com (8.15.2/8.15.2) with ESMTPS id x1S9TCj3007627 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 28 Feb 2019 09:29:12 GMT
Received: from xch-rcd-007.cisco.com (173.37.102.17) by XCH-ALN-008.cisco.com (173.36.7.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 28 Feb 2019 03:29:11 -0600
Received: from xch-rcd-007.cisco.com ([173.37.102.17]) by XCH-RCD-007.cisco.com ([173.37.102.17]) with mapi id 15.00.1395.000; Thu, 28 Feb 2019 03:29:11 -0600
From: "Rob Wilton (rwilton)" <rwilton@cisco.com>
To: Robert Varga <nite@hq.sk>, "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: [netmod] RFC7952 JSON streaming decoding efficiency?
Thread-Index: AQHUzuuJVNQCQ66ge0a+WQBULprZtqX08KGA
Date: Thu, 28 Feb 2019 09:29:11 +0000
Message-ID: <822cb25f1b894be9953a49ae12c91df9@XCH-RCD-007.cisco.com>
References: <022ede1d-a195-21db-f0b6-0c299a935f42@hq.sk>
In-Reply-To: <022ede1d-a195-21db-f0b6-0c299a935f42@hq.sk>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.63.23.61]
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-Outbound-SMTP-Client: 173.36.7.18, xch-aln-008.cisco.com
X-Outbound-Node: alln-core-1.cisco.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/7hLUSiBxx9Modi5ik8mjgd0hxfQ>
Subject: Re: [netmod] RFC7952 JSON streaming decoding efficiency?
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 28 Feb 2019 09:29:22 -0000

Hi Robert,

Isn't this just a limitation of JSON, in that the elements in an object are unordered (RFC 8259)?

Thanks,
Rob

-----Original Message-----
From: netmod <netmod-bounces@ietf.org> On Behalf Of Robert Varga
Sent: 27 February 2019 22:26
To: netmod@ietf.org
Subject: [netmod] RFC7952 JSON streaming decoding efficiency?

Hello,

reading RFC7952 sections 5.2.2-5.2.4, it would seem that metadata object
(5.2.2) can occur at any position in a JSON object, as well as metadata attachments to leaf/leaf-list/anyxml (5.2.3, 5.2.4) can occur any distance (before or after) from the data element they attach to.

The examples list the metadata object as the first item, and attachments immediately after the data element, but I could find no text which would make this required or recommended for document producers.

While this is completely workable when the parsing state is received into a mutable structure, it requires full parser event buffering in streaming setups.

One example would be JSON->XML transformation using token streaming interfaces (like GSON's JsonReader and
javax.xml.stream.XMLStreamWriter): since metadata can occur at any place in JSON, but is required to be emitted just after opening XML element, we must completely parse the JSON document before we can start emitting the XML document.

Is this intentional or just an omission?

Thanks,
Robert