FAQ
If I pass a primitive type of a struct to json.Decoder.Decode() it will do
it's best to decode the json into it. If I pass interface{} instead it will
do a "generic" decoding.

Is there a function in std library or anywhere else that can then transform
this interface{} to primitive or struct, just like if I passed it directly
to Decode()?

--
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

  • Ingo Oeser at Jul 6, 2015 at 3:55 pm
    Decoding to struct is possible using http://godoc.org/github.com/mitchellh/mapstructure

    For primitive types you could use a type assertion.

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 6, '15 at 7:58a
activeJul 6, '15 at 3:55p
posts2
users2
websitegolang.org

2 users in discussion

Bojan85: 1 post Ingo Oeser: 1 post

People

Translate

site design / logo © 2022 Grokbase