Duplicate key in json


#1

referenceImage

I’m trying to create tree layout by importing JSON file. I have duplicate keys in my JSON and I want to have loop links for every duplicate key. I have attached image and JSON for better understanding.

Like you can see in the image, I want to have a link from 0x81000020 to 0x8100003c. But, it is creating another node with 0x8100003c2.

Here is my json:
[
{ “name”: “0x81000000”, “key”: “0x81000000”},
{ “parent”: “0x81000000”, “name”: “0x8100002c”, “key”: “0x8100002c”},
{ “parent”: “0x81000000”, “name”: “0x8100001c”, “key”: “0x8100001c”},
{ “parent”: “0x8100002c”, “name”: “0x8100003c”, “key”: “0x8100003c”},
{ “parent”: “0x8100001c”, “name”: “0x81000020”, “key”: “0x81000020”},
{ “parent”: “0x81000020”, “name”: “0x8100003c”, “key”: “0x8100003c”}
]

Please help, as I am new to GoJS. Thanks in advance.


#2

What you want is not tree-structured, so you cannot use a TreeModel. https://gojs.net/latest/intro/usingModels.html#KindsOfModels

Furthermore key values must be unique. https://en.m.wikipedia.org/wiki/Unique_key