Skip to content

Instantly share code, notes, and snippets.

@harlow harlow/profile.go
Last active Mar 11, 2017

Embed
What would you like to do?
Struct w/ return vals from Aboutme API
// if "name" is returned as `[]` in JSON payload the json.Unmarshal func will panic in Golang
// Name struct {
// GivenName string `json:"givenName"`
// FamilyName string `json:"familyName"`
// Formatted string `json:"formatted"`
// } `json:"name"`
type Profile struct {
ID string `json:"id"`
Hash string `json:"hash"`
RequestHash string `json:"requestHash"`
ProfileURL string `json:"profileUrl"`
PreferredUsername string `json:"preferredUsername"`
ThumbnailURL string `json:"thumbnailUrl"`
DefaultAvatar bool `json:"defaultAvatar"`
Photos []struct {
Value string `json:"value"`
Type string `json:"type"`
} `json:"photos"`
Name struct {
GivenName string `json:"givenName"`
FamilyName string `json:"familyName"`
Formatted string `json:"formatted"`
} `json:"name"`
DisplayName string `json:"displayName"`
CurrentLocation string `json:"currentLocation"`
Accounts []struct {
Domain string `json:"domain"`
Display string `json:"display"`
URL string `json:"url"`
Username string `json:"username"`
Verified string `json:"verified"`
Shortname string `json:"shortname"`
} `json:"accounts"`
Urls []struct {
Value string `json:"value"`
Title string `json:"title"`
} `json:"urls"`
}
{
"entry": [{
"id": "24093338",
"hash": "f5a714266c7ea5ea163cddc8d30bc53e",
"requestHash": "569fd44396d10a2f3aefb7b868e5e322",
"profileUrl": "http:\/\/gravatar.com\/oniiru",
"preferredUsername": "oniiru",
"thumbnailUrl": "https:\/\/secure.gravatar.com\/avatar\/f5a714266c7ea5ea163cddc8d30bc53e",
"photos": [{
"value": "https:\/\/secure.gravatar.com\/avatar\/f5a714266c7ea5ea163cddc8d30bc53e",
"type": "thumbnail"
}],
"name": [],
"displayName": "oniiru",
"urls": []
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.