ben on Nostr: map[string]any is good if you don’t know the types ahead of time. otherwise you ...
map[string]any is good if you don’t know the types ahead of time. otherwise you should define a type struct with fields.
type User struct {
Name string ‘json:”name”’
}
var user User
json.Unmarshal(data, &user)
Published at
2024-06-15 04:27:42Event JSON
{
"id": "ea8282d77d1befda09a34639b7c4dcb6fffdf89e3e84e1c641745a788c73f7a6",
"pubkey": "7bdef7bdebb8721f77927d0e77c66059360fa62371fdf15f3add93923a613229",
"created_at": 1718425662,
"kind": 1,
"tags": [
[
"e",
"2a0011e347b4166009aea71710d3d298908524d5781556ff41bf6b0c23857d9c",
"",
"root"
],
[
"e",
"ae2975013c5045741f1899d7db2d0e094932b274b05e18a37febe28f010fedd9",
"",
"reply"
],
[
"p",
"347a2370900d19b4e4756221594e8bda706ae5c785de09e59e4605f91a03f49c"
],
[
"p",
"7bdef7bdebb8721f77927d0e77c66059360fa62371fdf15f3add93923a613229"
]
],
"content": "map[string]any is good if you don’t know the types ahead of time. otherwise you should define a type struct with fields.\n\ntype User struct {\n Name string ‘json:”name”’\n}\n\nvar user User\njson.Unmarshal(data, \u0026user)",
"sig": "5468adda22c9adec636678abac59af030ac791b47038e4f8ef2b855494a70435e41cc89fd0d39fb44d5ab47b072d064f0bccbca5bbb9f3fb517b58b3429db5c0"
}