From 7d71e555cbee85547a28293f4305f78457a4498a Mon Sep 17 00:00:00 2001 From: Marius Orcsik Date: Thu, 14 Feb 2019 20:08:52 +0100 Subject: [PATCH] Added unmarshaling of actors --- actors.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/actors.go b/actors.go index cd49766..2b4074e 100644 --- a/actors.go +++ b/actors.go @@ -134,3 +134,20 @@ func ServiceNew(id as.ObjectID) *Service { o := Service(*a) return &o } + +func (a *actor)UnmarshalJSON(data []byte) error { + as.ItemTyperFunc = JSONGetItemByType + + a.Parent.UnmarshalJSON(data) + a.PreferredUsername = as.JSONGetNaturalLanguageField(data, "preferredUsername") + a.Followers = as.JSONGetItem(data, "followers") + a.Following = as.JSONGetItem(data, "following") + a.Inbox = as.JSONGetItem(data, "inbox") + a.Outbox = as.JSONGetItem(data, "outbox") + a.Liked = as.JSONGetItem(data, "liked") + // TODO(marius): Endpoints need their own UnmarshalJSON + //a.Endpoints = as.JSONGetItems(data, "endpoints") + // TODO(marius): Streams needs custom unmarshalling + //a.Streams = as.JSONGetItems(data, "streams") + return nil +}