[netmod] JSON to XML lossy conversion

Michal Vaško <mvasko@cesnet.cz> Thu, 16 July 2020 14:24 UTC

Return-Path: <mvasko@cesnet.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost []) by ietfa.amsl.com (Postfix) with ESMTP id B99F63A0917 for <netmod@ietfa.amsl.com>; Thu, 16 Jul 2020 07:24:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.319
X-Spam-Status: No, score=-1.319 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cesnet.cz
Received: from mail.ietf.org ([]) by localhost (ietfa.amsl.com []) (amavisd-new, port 10024) with ESMTP id 8BXS0-JzxDMQ for <netmod@ietfa.amsl.com>; Thu, 16 Jul 2020 07:24:48 -0700 (PDT)
Received: from kalendar.cesnet.cz (kalendar.cesnet.cz [IPv6:2001:718:1:1f:50:56ff:feee:34]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3EA893A08DB for <netmod@ietf.org>; Thu, 16 Jul 2020 07:24:46 -0700 (PDT)
Received: by kalendar.cesnet.cz (Postfix, from userid 999) id 724E0601A4; Thu, 16 Jul 2020 16:24:43 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=kalendar; t=1594909483; bh=VroDWP0bP4N59+OE1c1h7z9dTuerd8Z7QsKOfW7iCtE=; h=To:Date:Subject:From; b=aN7riZFc/C1VF1H5Ea0kiqbEYEqjgwLf2NVNcJcFgXR7D96Dtdfc/cN0KwtdFQIsR 8oFdYZlYmttp8aD78wnoWgoIE0R52mWtpLFGT/m2xUSYCBfl5+POOAlUWWWZfL49MB CEpkpzn6cj+3zh/FLfQrxn856aiaoXq6vAx/0eoQ=
Content-Type: text/plain; charset="utf-8"
To: netmod <netmod@ietf.org>
User-Agent: SOGoMail 2.3.23
MIME-Version: 1.0
Date: Thu, 16 Jul 2020 16:24:43 +0200
Message-ID: <15dd-5f106300-3d-41094600@245675998>
X-Forward: 2001:67c:1220:80c:b5:55d3:81d5:8636
From: Michal Vaško <mvasko@cesnet.cz>
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/5B_pP4yQ_n3yfg1Ao7A-xW6RXeA>
Subject: [netmod] JSON to XML lossy conversion
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, 16 Jul 2020 14:24:53 -0000

it seems that there are cases when YANG data represented in JSON include more information than when converted to XML. Example:


module a {
  leaf l {
    type union {
      type string;
      type uint8;


  "a:l": 20

These data will be parsed as the leaf "l" of type "uint8" based on the JSON specs [1]. Then, when printed again



this XML would be parsed as leaf "l" of type "string".

Similar problem occurs also for boolean. So I am just wondering, is this a known bug/feature, is it intentional? It is true that applications usually choose one format and stick to it but it is not a requirement and I can see this having possibly quite nasty consequences.


[1] https://tools.ietf.org/html/rfc7951#section-6.10