lets say i have a json response like this, as you can see sometimes email exists sometimes not. now i need to check the email key exists or not and pretty print the json response accordingly. how can i do this?
[ {"name" : "name1", "mobile": "123", "email": "[email protected]", "carrier": "carrier1", "city", "city1"}, {"name" : "name2", "mobile": "1234", "carrier": "carrier2", "city", "city2"} ... ] here i need to check the p.Email exists or not, if it exists assign the email value if not assign empty string
for i, p := range jsonbody.Data { a := p.Name b := p.Phone[i].Mobile c := p.INTaddress[i].Email // here i need to check d := p.Phone[i].Carrier e := p.Address[i].City .......... } i tried searching but not found any answers for golang.