Member-only story
Parse Json
Retrieve json field value without proper defining struct in Go
For example you want to retrieve variant_id from this json
"_shards": {
"total": 20,
"successful": 20,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 150798,
"max_score": 6.5599113,
"hits": [
{
"_index": "zz",
"_type": "3",
"_id": "1",
"_score": 6.5599113,
"_source": {
"project_id": "xxxx",
"auth_resource_path": "/programs/DGV4VN/projects/VN1000G",
"variant_id": "tttt",
"flag": true,
"allele": "?",
"consequence": "?",
"impact": "zz",
"symbol": "l",
"gene": "z",
"feature_type": "z",
"feature": "z",
"biotype": "z",
"hgvsc": "k",
"strand": "-1",... }
},
{
...
}
},
]
}
}
Hope it helps.
Happy coding!