Skip to content

Printing JSON structure #111

@VascoSch92

Description

@VascoSch92

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions