I have a bunch of JSON files that I need to Unmarshal. They have basically the same format, but different "length"
one example
https://pastebin.com/htt6k658
another example
https://pastebin.com/NR1Z08f4
I have tried several methods, like building structs like
type TagType struct {
ID int `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
tags []Tag `json:"tags"`
}
type Tag struct {
ID int `json:"users"`
Name string `json:"name"`
Slug string `json:"slug"`
}
also with an interface, like
json.Unmarshal([]byte(empJson), &result)
but none of these methods worked.
2
Answers
The JSON input is an array, so this should work:
You can use a online tool like https://transform.tools/json-to-go for generating the Go struct: