mholt/json-to-go

Error parsing [][]string structure

theriverman opened this issue · 1 comments

Hi,

The following JSON is parsed incorrectly when NOT using inline structures:

{
  "assigned_to": 7,
  "tags": [
    [
      "hello",
      "#ab14d9"
    ]
  ]
}

When using inline structures, it's converted as expected:

type AutoGenerated struct {
	AssignedTo int        `json:"assigned_to"`
	Tags       [][]string   `json:"tags"`
}

When NOT using inline structures, parsing fails:

3:13: expected ';', found '[' (and 1 more errors)

It should return something like:

type Tags [][]string
type AutoGenerated struct {
	AssignedTo int        `json:"assigned_to"`
	Tags       Tags          `json:"tags"`
}

Thanks for the awesome tool!

lhlyu commented

@theriverman

You can try this online tool