提问人:An art 提问时间:3/17/2022 更新时间:3/17/2022 访问量:150
Go grammes - 如何从 Gremlin 获取属性,而不仅仅是使用 Go grammes 获取值
go grammes - how to get property from gremlin, not just the value with go grammes
问:
您好,我正在使用 golang 包“github.com/northwesternmutual/grammes”,并希望从响应客户端获取字段而不仅仅是值,以便我可以将其解码为 JSON
data, err := client.ExecuteQuery(g.V().Has("person", "name", "aksan").Values())
if err != nil {
log.Fatalf("Querying error: %s", err.Error())
}
var responseStruct map[string]interface{}
err = json.Unmarshal(data[0], &responseStruct)
if err != nil {
log.Fatalf("unmarshal error: %s", err.Error())
}
// Log out the response.
PrettyPrint(responseStruct["@value"], "result")
响应是
[
{
"@type": "g:Int64",
"@value": 6
},
"p01",
{
"@type": "g:Int64",
"@value": 10
},
"aksan",
{
"@type": "g:Int32",
"@value": 29
}
]
我想要的是结果将显示字段喜欢@fields或类似的东西
[
"height":{
"@type": "g:Int64",
"@value": 6
},
"code":"p01",
"weight":{
"@type": "g:Int64",
"@value": 10
},
"name":"aksan",
"age":{
"@type": "g:Int32",
"@value": 29
}
]
答:
3赞
Rahmat Fathoni
3/17/2022
#1
用代替ValueMap()
Values()
评论