Skip to content
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

fix empty nodes #251

Merged
merged 7 commits into from
Nov 7, 2022
Merged

fix empty nodes #251

merged 7 commits into from
Nov 7, 2022

Conversation

victorbrambati
Copy link
Contributor

I created the PR #242 but the updates created a conflict with my old PR. This PR solve the same problem, I tested the problems from #242 and it work correctly. Thank you for the patience.

@AykutSarac
Copy link
Owner

It works so great, thanks so much for that I'll be following up and testing this! Would you be able to make improvements for this to work? #181

@victorbrambati
Copy link
Contributor Author

victorbrambati commented Oct 31, 2022

It works so great, thanks so much for that I'll be following up and testing this! Would you be able to make improvements for this to work? #181

Yes I created it now, but to not bug all UI of graph I put it only in objects out of an array, I don't know if the PR #181 is better choose, but to you compare I printed the graph:

Result of #181:
image
{ _id: "generated", field: "value", object: { fieldA: "valA", ObjectNestA: { fieldNestA: "valB", }, }, }

Result of the first example in #242:

image
{ "properties": { "definitions": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, "deprecated": true } } }

You want that I push this commit?

@AykutSarac
Copy link
Owner

Yes, please push the commit. II'll test it with more data and share my feedbacks with you.

@AykutSarac
Copy link
Owner

There's this issue, if there is a single object. The fields with string should be in a single node and rest should be connected to it. From this JSON it works very different that you will notice:

{
  "id": "AAL",
  "identifiers": [
    {
      "identifier": "AAL",
      "scheme": "SPDX"
    },
    {
      "identifier": "License :: OSI Approved :: Attribution Assurance License",
      "scheme": "Trove"
    }
  ],
  "links": [
    {
      "note": "OSI Page",
      "url": "https://opensource.org/licenses/AAL"
    }
  ],
  "name": "Attribution Assurance License",
  "other_names": [],
  "superseded_by": null,
  "keywords": [
    "osi-approved",
    "discouraged",
    "redundant"
  ],
  "text": [
    {
      "media_type": "text/html",
      "title": "HTML",
      "url": "https://opensource.org/licenses/AAL"
    }
  ]
}

How it looks in the PR:
image

How it should look:
image

I'm guessing it happens because nodes are created right after a line is read and not until whole object is did read?
You can compare PR with the existing version using the following json: https://api.opensource.org/licenses/

Thanks again for putting your effort into this, you will make a significant impact on this project :)

@AykutSarac
Copy link
Owner

For example for the default json, if I move one line to bottom the view changes:
image

{
  "squadName": "Super hero squad",
  "homeTown": "Metro City",
  "formed": 2016,
  "secretBase": "Super tower",
  "members": [
    {
      "name": "Molecule Man",
      "age": 29,
      "secretIdentity": "Dan Jukes",
      "powers": [
        "Radiation resistance",
        "Turning tiny",
        "Radiation blast"
      ]
    },
    {
      "name": "Madame Uppercut",
      "age": 39,
      "secretIdentity": "Jane Wilson",
      "powers": [
        "Million tonne punch",
        "Damage resistance",
        "Superhuman reflexes"
      ]
    },
    {
      "name": "Eternal Flame",
      "age": 1000000,
      "secretIdentity": "Unknown",
      "powers": [
        "Immortality",
        "Heat Immunity",
        "Inferno",
        "Teleportation",
        "Interdimensional travel"
      ]
    }
  ],
  "active": true
}

@AykutSarac
Copy link
Owner

AykutSarac commented Nov 1, 2022

Looks like when a parent node is collapsed and its parent is collapsed and expanded back, it's child disappears. Should be investigated later on after the parser is setup. This PR will make #161 possible ✨

@victorbrambati
Copy link
Contributor Author

victorbrambati commented Nov 1, 2022

About this issue, is to make it too to fields with string that have parents? Because your example only have nodes that not have a parent.
Example:

{
  "one": {
    "sa": "sa",
    "si": "si",
    "right": {
      "example": "example"
    },
    "cg": "Cg"
  }
}

"sa": "sa", "si": "si" and "cg": "Cg" is to be the same node or "cg": "Cg" is to be separated of others in other node?

@victorbrambati
Copy link
Contributor Author

Looks like when a parent node is collapsed and its parent is collapsed and expanded back, it's child disappears. Should be investigated later on after the parser is setup. This PR will make #161 possible sparkles

Amazing! ✨

@AykutSarac
Copy link
Owner

About this issue, is to make it too to fields with string that have parents? Because your example only have nodes that not have a parent. Example:

{
  "one": {
    "sa": "sa",
    "si": "si",
    "right": {
      "example": "example"
    },
    "cg": "Cg"
  }
}

"sa": "sa", "si": "si" and "cg": "Cg" is to be the same node or "cg": "Cg" is to be separated of others in other node?

No, what I mean here is when going through inside of an object e.g.

{
  "str1": "string",
  "array": ["hi", "ho"],
  "str2": "string2"
}

String values inside of an object should create a single object and rest should be seperated and connected same as how current jsoncrack.com works.

How it is:
image

How it should be:
image

@victorbrambati
Copy link
Contributor Author

You want that the childrens of an object without a key into an array repeat the same behavior expected? (because in this new commit it doesn't happen)

@AykutSarac
Copy link
Owner

You want that the childrens of an object without a key into an array repeat the same behavior expected? (because in this new commit it doesn't happen)

Can you elaborate with example of data? I think with the latest commit all seems fine.

@victorbrambati
Copy link
Contributor Author

Can you elaborate with example of data? I think with the latest commit all seems fine.

Yes, the commit 76bcad4 kept separated the brothers node in a object from array.

This example was obtained in: https://api.opensource.org/licenses/

[ { "id": "AAL", "identifiers": [ { "identifier": "AAL", "scheme": "SPDX" }, { "identifier": "License :: OSI Approved :: Attribution Assurance License", "scheme": "Trove" } ], "links": [ { "note": "OSI Page", "url": "https://opensource.org/licenses/AAL" } ], "name": "Attribution Assurance License", "other_names": [], "superseded_by": null, "keywords": [ "osi-approved", "discouraged", "redundant" ], "text": [ { "media_type": "text/html", "title": "HTML", "url": "https://opensource.org/licenses/AAL" } ] }, { "id": "AFL-3.0", "identifiers": [ { "identifier": "AFL-3.0", "scheme": "SPDX" }, { "identifier": "License :: OSI Approved :: Academic Free License (AFL)", "scheme": "Trove" } ], "links": [ { "note": "OSI Page", "url": "https://opensource.org/licenses/AFL-3.0" } ], "name": "Academic Free License, Version 3.0", "other_names": [], "superseded_by": null, "keywords": [ "osi-approved", "discouraged", "redundant" ], "text": [ { "media_type": "text/html", "title": "HTML", "url": "https://opensource.org/licenses/AFL-3.0" } ] } ]

commit 76bcad4:

image

new commit e772153:
image

@victorbrambati
Copy link
Contributor Author

Now with the last commit e772153 all seems fine.

@AykutSarac
Copy link
Owner

Thank you Victor! Finally, I believe it would be a better UX experience to not have a root node if there's an array of object at root level independent of each other like in the https://api.opensource.org/licenses/

So, same as the current version can we keep them seperated without connections?

[
  {
    "id": "Zlib",
    "identifiers": [
      {
        "identifier": "Zlib",
        "scheme": "DEP5"
      },
      {
        "identifier": "Zlib",
        "scheme": "SPDX"
      },
      {
        "identifier": "License :: OSI Approved :: zlib/libpng License",
        "scheme": "Trove"
      }
    ],
    "links": [
      {
        "note": "OSI Page",
        "url": "https://opensource.org/licenses/Zlib"
      }
    ],
    "name": "The zlib/libpng License (Zlib)",
    "other_names": [],
    "superseded_by": null,
    "keywords": [
      "osi-approved"
    ],
    "text": [
      {
        "media_type": "text/html",
        "title": "HTML",
        "url": "https://opensource.org/licenses/Zlib"
      }
    ]
  },
  {
    "id": "jabberpl",
    "identifiers": [
      {
        "identifier": "License :: OSI Approved :: Jabber Open Source License",
        "scheme": "Trove"
      }
    ],
    "links": [
      {
        "note": "OSI Page",
        "url": "https://opensource.org/licenses/jabberpl"
      }
    ],
    "name": "Jabber Open Source License",
    "other_names": [],
    "superseded_by": null,
    "keywords": [
      "discouraged",
      "retired",
      "osi-approved"
    ],
    "text": [
      {
        "media_type": "text/html",
        "title": "HTML",
        "url": "https://opensource.org/licenses/jabberpl"
      }
    ]
  }
]

image

@victorbrambati
Copy link
Contributor Author

@AykutSarac Yes. I will commit now.

@AykutSarac AykutSarac added the enhancement Improve performance or optimization label Nov 5, 2022
@AykutSarac
Copy link
Owner

Awesome work @victorbrambati! Parser seems ready to be merged, now I'm investigate the collapse/expand issue and I'll commit whenever I find a solution. You may want to take a look if you have an idea.

{
  "ankara": {
    "name": "name",
    "username": "username",
    "password": "password",
    "servers": [
      {
        "ipaddress": "10.10.10.10",
        "listenport": 4222,
        "clusterport": 6112
      }
    ]
  }
}

@victorbrambati
Copy link
Contributor Author

Awesome work @victorbrambati! Parser seems ready to be merged, now I'm investigate the collapse/expand issue and I'll commit whenever I find a solution. You may want to take a look if you have an idea.

{
  "ankara": {
    "name": "name",
    "username": "username",
    "password": "password",
    "servers": [
      {
        "ipaddress": "10.10.10.10",
        "listenport": 4222,
        "clusterport": 6112
      }
    ]
  }
}

It happen when a parent connect a parent directly, before that did not happen. Probrably is a problem in algorithm of a collapsed nodes that it was not thought to work in these circumstances.

@victorbrambati
Copy link
Contributor Author

@AykutSarac I found a solution:

@AykutSarac
Copy link
Owner

Awesome work @victorbrambati, I'm merging this now with the main branch 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve performance or optimization
Projects
None yet
2 participants