-
Notifications
You must be signed in to change notification settings - Fork 1
Wrong typedef output #6
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
Comments
Hello! Great question and this might not be obvious, but since you're actually passing a string (of JSON), the idea is to use the schema := jtdinfer.
InferStrings(
[]string{`{"name":"Joe", "age": 52, "something_optional": true, "something_nullable": 1.1}`},
jtdinfer.WithoutHints(),
).
IntoSchema()
j, _ := json.MarshalIndent(schema, "", " ")
fmt.Println(string(j)) Output: {
"properties": {
"age": {
"type": "uint8"
},
"name": {
"type": "string"
},
"something_nullable": {
"type": "float64"
},
"something_optional": {
"type": "boolean"
}
}
} The schema := jtdinfer.
NewInferrer(jtdinfer.WithoutHints()).
Infer(map[string]any{
"name": "Joe",
"age": 52,
"something_optional": true,
"something_nullable": 1.1,
}).
IntoSchema()
j, _ := json.MarshalIndent(schema, "", " ")
fmt.Println(string(j)) What's happening under the hood when you call |
I created #7 which updates the readme and adds more examples, hope that helps! |
Totally |
Output:
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: