Fix anyxml-to-JSON translation duplication error 44/96944/9
authorManoj Chokka <cmanoj8@gmail.com>
Tue, 20 Jul 2021 12:38:00 +0000 (12:38 +0000)
committerRobert Varga <nite@hq.sk>
Tue, 1 Nov 2022 15:46:39 +0000 (15:46 +0000)
commitfbc5e2f1e1b7fab6bfcccf64409d07224c1270db
treebb19aa785fc4e54578d082bc5d5c37c892420f40
parentb014649ba98a64037de79353dc25cd9489441c29
Fix anyxml-to-JSON translation duplication error

JSONNormalizedNodeStreamWriter generates duplicates when array elements
are not listed consecutively and interleaved with other sibling nodes.
Make sure to check if there is any previously processed sibling node
with the same node name instead of checking just the previous one.

Also, Add a couple of test cases to cover this issue.

JIRA: YANGTOOLS-1302
Change-Id: I4d64c8b8a45009e7667af621c96c34824fb7b48b
Signed-off-by: Manoj Chokka <cmanoj8@gmail.com>
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
codec/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONNormalizedNodeStreamWriter.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java
codec/yang-data-codec-gson/src/test/resources/complexjson/yang/yt1302.yang [new file with mode: 0644]
codec/yang-data-codec-gson/src/test/resources/yt1302/json/array-of-array.json [new file with mode: 0644]
codec/yang-data-codec-gson/src/test/resources/yt1302/json/flat-array.json [new file with mode: 0644]
codec/yang-data-codec-gson/src/test/resources/yt1302/xml/array-of-array.xml [new file with mode: 0644]
codec/yang-data-codec-gson/src/test/resources/yt1302/xml/flat-array.xml [new file with mode: 0644]