Skip to content

Instantly share code, notes, and snippets.

@allienna
Last active September 21, 2018 07:39
Show Gist options
  • Save allienna/4ee0cad8589e1d59986cf0839b9ea077 to your computer and use it in GitHub Desktop.
Save allienna/4ee0cad8589e1d59986cf0839b9ea077 to your computer and use it in GitHub Desktop.
Jsonpath to json schema requirement
I would like to generate a json schema from a list of jsonpath.
Example:
For this kind of input,
```
$.firstName
$.lastName
$.address.streetAddress
$.address.city
$.address.postalCode
$.phoneNumbers[0].type
$.phoneNumbers[0].number
```
the result should be:
```
{
"firstName": "John",
"lastName" : "doe",
"address" : {
"streetAddress": "",
"city" : "",
"postalCode" : ""
},
"phoneNumbers": [
{
"type" : "",
"number": ""
}
]
}
```
From now, I don't know how can I do this... So, if someone have some kind of algorithm in mind, I'll take it :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment