FAQ
type Parent struct {
     ID int
     Child interface{}
}

type ChildT struct {
     ID int
}


json string {"ID":2,"Child":{"ID":3}}

When field Child has value ChildT{}, field Child unmarshals into type
map[string]int
When field Child has value &ChildT{}, field Child unmarshals into type
*ChildT.

https://play.golang.org/p/LkbbOz0ytb


--
苏沛

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 27, '16 at 10:58a
activeMay 27, '16 at 1:51p
posts2
users2
websitegolang.org

2 users in discussion

苏沛: 1 post James Bardin: 1 post

People

Translate

site design / logo © 2021 Grokbase