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

Printing JSON structure #111

Open
VascoSch92 opened this issue Sep 28, 2023 · 3 comments
Open

Printing JSON structure #111

VascoSch92 opened this issue Sep 28, 2023 · 3 comments

Comments

@VascoSch92
Copy link

Hey,
I am using pysimdjson very often to work with JSON and I appreciate the speed and the intuitiveness of the package. Generally, I use it when I need to look directly into specific JSON for information (debug mode).

However, when I start exploring a JSON it would be useful to have a function to print the structure (or the schema of the JSON) so that we can move faster.

i will give you an example.
Suppose we have the JSON example:

{
  "owner": {
    "name": "Mike",
    "age": "24",
    "sex": "M"
  },
  "dogs": [
    {
      "name": "Charly",
      "age": 1,
      "sex": "M"
    },
    {
      "name": "Vanessa",
      "age": 2,
      "sex": "S"
    }
  ]
}

then i can write example.schema() (or example.structure() ) and the output will be:

root
 |- owner
 |   |- name
 |   |- age
 |   |- sex
 |- dogs
 |   |- array type
 |       |- name
 |       |- age
 |       |- sex

Is there already something in like that in the package?

@lneukom
Copy link

lneukom commented Oct 9, 2023

This is exactly what I was looking for. It would also be very useful for me :-)

@lemire
Copy link
Contributor

lemire commented Oct 9, 2023

Intriguing. Is there some kind of specification for such outputs?

@VascoSch92
Copy link
Author

Nothing special... Just a tree with the json structure. It is not hard to implement it as a Python method but it slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants