Closed sbres closed 2 years ago
Thanks for reducing down the problem! I just pasted in your structure and it works just fine for me:
type AutoGenerated []struct {
Holder1 struct {
Type1 [][]string `json:"type1"`
} `json:"holder1"`
}
I just tried it again.
It does work when "Inline type definitions" is set, but not when it's not set.
Ah, you're right. @mahdi-hosseini any idea what might be causing this?
Oh, and to be clear, I suspect this might be the output of gofmt
, i.e. the Go code we generate is not syntactically valid.
Ah, you're right. @mahdi-hosseini any idea what might be causing this?
Hi Matt, I will look into it this weekend!
The issue does not seem to be caused by gofmt
but rather the output of jsonToGo()
is invalid Go struct
. There is an extraneous Type1
in the output when the function is called with flatten = true
, see here: https://play.golang.org/p/tpFHAOmFQk8
So this is probably a bug. I may be able to look into it further when I have the time.
Ah, nice catch. Thanks for looking into it!
I encountered the same problem. Just wondering if there is a work around for this issue.
Excellent tool, by the way.
I've done a check and the website is able to convert the JSON to a go struct
First of all, thank you for this tool it is very helpful.
I was trying to encode this value:
[{"holder1": {"type1": [["value1", "value2"], ["value1", "value2"]]}}]
And it resulted in this error:
5:15: expected ';', found '[' (and 1 more errors)
The smallest structure that still shows the error is the following.
[{"holder1": {"type1": [["value"]]}}]