How to parse an inner field in a nested JSON object

后端 未结 5 1235
一生所求
一生所求 2021-01-31 08:26

I have a JSON object similar to this one:

{
  \"name\": \"Cain\",
  \"parents\": {
    \"mother\" : \"Eve\",
    \"father\" : \"Adam\"
  }
}

No

5条回答
  •  不思量自难忘°
    2021-01-31 08:37

    More recently, gjson supports selection of nested JSON properties.

    name := gjson.Get(json, "name")
    mother := gjson.Get(json, "parents.mother")
    

提交回复
热议问题