Is there anyway to get the json object keys
Closed this issue · 4 comments
aqsyonas commented
Greetings,
I would like to extract the keys from below json object. Is there any way using to it this library?
{
"id": 790,
"sid": "7ktsfm@127.0.0.1",
"dstHost": "55.23.220.21",
"srcHost": "58.226.2.241",
"dstId": "55.23.220.21:5060",
"srcId": "58.226.2.241:5064",
"srcIp": "58.226.2.241",
"dstIp": "55.23.220.21",
"srcPort": 5064,
"aliasSrc": "58.226.2.241:5064",
"aliasDst": "55.23.220.21:5060",
"dstPort": 5060,
"method": "INVITE",
"method_text": "INVITE",
"create_date": "2019-09-04T14:44:10.7896334+05:00",
"protocol": 17,
"msg_color": "blue",
"ruri_user": "INVITE sip:196@sipcapture.org;user=phone SIP/2.0\r\n",
"destination": 1,
"micro_ts": "0001-01-01T00:00:00Z"
}
Best Regards,
Jeffail commented
Hey @aqsyonas, you can iterate the keys of https://godoc.org/github.com/Jeffail/gabs#Container.ChildrenMap with for key := range g.Children()
.
aqsyonas commented
@Jeffail thanks that was really quick. :)
I have another question. It is possible to check value existence in an array using some function or i need to loop over them using Children method?
{"keys":["10","20"]}
would like to see if "10" exists in array?
Br, Aqs.
aqsyonas commented
Thank you..!