FAQ
I set a json object to map[string]interface{}, I can reference the root
indexes via jsonObj["someIndex"] but I can't go deeper like
jsonObj["someIndex"]["childIndex"], any easy way to assert interface{} to
map?

--
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/groups/opt_out.

Search Discussions

  • Ray Long at Oct 1, 2013 at 7:07 am
    Let's assume your interface{} type is map[string]bool, then you can visit
    like this

    var b bool = jsonObj["someIndex"].(map[string]bool)["childIndex"]

    在 2013年10月1日星期二UTC+8上午11时13分33秒,Tobias Contreras写道:
    I set a json object to map[string]interface{}, I can reference the root
    indexes via jsonObj["someIndex"] but I can't go deeper like
    jsonObj["someIndex"]["childIndex"], any easy way to assert interface{} to
    map?
    --
    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/groups/opt_out.
  • Tobias Contreras at Oct 1, 2013 at 2:07 pm
    Awesome, thanks that was it... i sweared I tried that but... oh well,
    thanks again for the clarification!
    On Tuesday, October 1, 2013 1:07:07 AM UTC-6, Ray Long wrote:

    Let's assume your interface{} type is map[string]bool, then you can visit
    like this

    var b bool = jsonObj["someIndex"].(map[string]bool)["childIndex"]

    在 2013年10月1日星期二UTC+8上午11时13分33秒,Tobias Contreras写道:
    I set a json object to map[string]interface{}, I can reference the root
    indexes via jsonObj["someIndex"] but I can't go deeper like
    jsonObj["someIndex"]["childIndex"], any easy way to assert interface{} to
    map?
    --
    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/groups/opt_out.
  • Morozov Alexandr at Oct 1, 2013 at 1:36 pm
    You can set initial structure to map[string]map[string]interface{}. Or you
    can do type assertion: jsonObj["someIndex"].(map[string]interface{})


    вторник, 1 октября 2013 г., 7:13:33 UTC+4 пользователь Tobias Contreras
    написал:
    I set a json object to map[string]interface{}, I can reference the root
    indexes via jsonObj["someIndex"] but I can't go deeper like
    jsonObj["someIndex"]["childIndex"], any easy way to assert interface{} to
    map?
    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 1, '13 at 3:13a
activeOct 1, '13 at 2:07p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase