it should be trivial to just extract the id
from the inlined actor if you really must fetch it…
ideally, regardless of whether you used json or json-ld, you would be using a partial hydration strategy to expand the object (or graph) as needed. meaning, you would store nodes by their id and inject them into the json object (or the json-ld graph) as needed from your cache or via a network request.
example: you try to access actor.name
but fail because that node has not been hydrated yet:
{
"actor": "https://fed.brid.gy/snarfed.org",
"object": "http://ds9.lemmy.ml/comment/1",
"audience": "https://enterprise.lemmy.ml/c/tenforward",
"type": "Like",
"id": "https://fed.brid.gy/activities/like/fd61d070-7382-46a9-b2b7-6bb253732877"
}
so you try to expand the actor
property:
{
"actor": {
"url": "https://fed.brid.gy/r/https://snarfed.org/",
"image": {
"url": "https://secure.gravatar.com/avatar/947b5f3f323da0ef785b6f02d9c265d6?s=96&d=blank&r=g",
"type": "Image"
},
"type": "Person",
"name": "Ryan Barrett",
"icon": {
"url": "https://secure.gravatar.com/avatar/947b5f3f323da0ef785b6f02d9c265d6?s=96&d=blank&r=g",
"type": "Image"
},
"id": "https://fed.brid.gy/snarfed.org",
"preferredUsername": "snarfed.org"
},
"object": "http://ds9.lemmy.ml/comment/1",
"audience": "https://enterprise.lemmy.ml/c/tenforward",
"type": "Like",
"id": "https://fed.brid.gy/activities/like/fd61d070-7382-46a9-b2b7-6bb253732877"
}
now you can access actor.name
successfully.
this way, if you are given an inline representation that you trust, you can just use it as-is. if you don’t trust it or it is not there, you can replace that node with a trusted version.