pysimdjson
pysimdjson copied to clipboard
Printing JSON structure
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?
This is exactly what I was looking for. It would also be very useful for me :-)
Intriguing. Is there some kind of specification for such outputs?
Nothing special... Just a tree with the json structure. It is not hard to implement it as a Python method but it slow.