swaggest / jsonschema-go

JSON Schema mapping for Go
https://pkg.go.dev/github.com/swaggest/jsonschema-go
MIT License
102 stars 13 forks source link

How to create JSON schema based on a JSON data? #84

Closed tpoxa closed 1 year ago

tpoxa commented 1 year ago

Another odd question from me.

I am considering using JSON Schema to analyse the data structure without getting the data itself. I know that is not precisely what this module is done for, but I still wonder if you might know or have any ideas @vearutop.

Thanks.

vearutop commented 1 year ago

Hi, I'm not sure if I can really understand

to analyse the data structure without getting the data itself

From the title of the issue I assume you may want to infer schema from data sample(s). If that's the case, have a look at https://github.com/swaggest/json-cli#buildschema and https://github.com/swaggest/json-schema-maker (DISCLAIMER: beware of PHP! 👻 ), later you can generate Go structures from such a schema with https://github.com/swaggest/json-cli#gengo.

If the problem you're trying to solve is different, please share some more details and/or examples.

tpoxa commented 1 year ago

Yes, that's the one I am trying to implement and generate JSON schema based on JSON data. Thanks for the tips. I'll take a look. PHP should be fine. I was Zend certified engineer many centuries ago.