The problem is that JSON can contain all kinds of fields and nested data and Go requires the schema to be declared ahead of time with struct declarations
However it's possible to load arbitrary JSON into Go anyway
Just load it into an empty interface
var data interface{}
json.Unmarshal([]byte(testdata), &data)
but then accessing fields in the data becomes a major pita. To achieve the same as above...
@vorsprung
thank you for answer me and sorry for very lately reply. I'm so busy. But for this problem look like i must use custom parser to work with this case. ( goyacc ).
my intend is you json as form ( json form-schema ) and anyone can create they form as need. that mean in server-side they need implement custom parser to get attribute they need. :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
OK, what you haven't explained is that in Go, JSON parsing can occur directly into structs
With your example, this is complicated with the need for a struct inside a struct
The problem is that JSON can contain all kinds of fields and nested data and Go requires the schema to be declared ahead of time with struct declarations
However it's possible to load arbitrary JSON into Go anyway
Just load it into an empty interface
but then accessing fields in the data becomes a major pita. To achieve the same as above...
@vorsprung thank you for answer me and sorry for very lately reply. I'm so busy. But for this problem look like i must use custom parser to work with this case. ( goyacc ).
my intend is you json as form ( json form-schema ) and anyone can create they form as need. that mean in server-side they need implement custom parser to get attribute they need. :)