-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Nested objects causing empty nodes #27
Comments
Hey @AykutSarac |
I appreciate it so much, the problem is likely to be caused by the algorithm at |
Okay, I will have a look at it. |
Is the empty node where the object properties that are not arrays or objects is shown? |
Following data is a good example of what's wrong when pasted to jsonvisio.com: {
"properties": {
"definitions": {
"type": "object",
"additionalProperties": {
"$dynamicRef": "#meta"
},
"deprecated": true
}
}
} |
Connecting edges to parent would not be visually suitable if there are siblings of the empty node, I've raised a pull request for this issue which handles this scenario as follows: |
@AykutSarac is there any progress on this issue? Was someone able to find the root cause for this issue? |
@noobyogi0010 The root issue is mainly because of the issue mentioned here: #51 The issue here is a node hides keys with values of Array or Objects to create seperate nodes, then the node displays single value keys such as bool, string or other kinds. When there is no other type like a number or string it becomes an empty node. If the issue I mentioned above gets resolved this will be solved mainly. Empty nodes could be handled as a next step after #51 gets resolved. I appreciate any sort of help. |
@AykutSarac |
I think the problem here is that the code is doing what it should do. Take a look at the file jsonParser.ts, inside it, every time you have a nested object, you convert it into something similar to an array to generate the children. That's the reason why using this example: {
"properties": {
"definitions": {
"type": "object",
"additionalProperties": {
"$dynamicRef": "#meta"
},
"deprecated": true
}
}
} You've got on the second node the word You can't tell if the associated value is either a nested object or an array of only one element. It is impossible, because on the transformation process, when you are generating the data structure that is going to be used later on to render edges and nodes, when you find a nested object, you turn it into an array, so that later on you can apply your function recursively to it's children. The problem is your nested objects are treated as an array, so some weird things will happen. Like this empty node with array subnodes. Here is the code & complete screenshot {
"squadName": "Super hero squad",
"homeTown": "Metro City",
"formed": 2016,
"secretBase": "Super tower",
"ArrayOrNestedObject?": {
"name": "Molecule Man",
"age": 29,
"secretIdentity": "Dan Jukes",
"powers": [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]
},
"active": true,
"members": [
{
"name": "Molecule Man",
"age": 29,
"secretIdentity": "Dan Jukes",
"powers": [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]
}
]
} I think to solve this issue, one must answer the question: How do I want to represent a nested object? Then, build a function that detects nested objects inside a JSON, and apply that function that will render something visually different from a nested array. Something clearly different. I like fractals, and I think whenever you have something nested in code, there is a fractal here. Eg, folders and files, you can apply the same function that renders the root folder to a nested folder, and it will render the file system nested. Each time you detect a folder, you can apply the same function that renders the original root folder. Take a look at "ArrayOrNestedObject" key here: Can you see the This approach is what I applied here With this approach, it is very simple to build any function to handle the data you are working on. Here is an example of a function that searches a subtree with an |
Issue
Empty nodes occurs in situations similar to nested objects.
Reproduction
Following data could be addressed regarding this: https://raw.githubusercontent.com/json-schema-org/json-schema-spec/draft-next/schema.json
Expected behaviour
Edges should be connected to parent instead.
The text was updated successfully, but these errors were encountered: