package ap_test import ( "fmt" "testing" "github.com/go-ap/jsonld" "github.com/stretchr/testify/require" "sectorinf.com/emilis/flabk/flabk/ap" ) func GetExample() ap.Object { return ap.Object{ Context: jsonld.Context{ { IRI: jsonld.IRI("https://www.w3.org/ns/activitystreams"), }, { Term: jsonld.LanguageKw, IRI: "en", }, }, Type: "Like", Actor: &ap.Actor{ ID: "https://dustycloud.org/chris/", }, Name: "Chris liked 'Minimal ActivityPub update client'", Object: &ap.Object{ ID: "https://rhiaro.co.uk/2016/05/minimal-activitypub", }, To: []ap.Object{ {ID: "https://rhiaro.co.uk/#amy"}, {ID: "https://dustycloud.org/followers"}, {ID: "https://rhiaro.co.uk/followers/"}, }, CC: []ap.Object{ {ID: "https://e14n.com/evan"}, }, } } func TestObject(t *testing.T) { that := require.New(t) result, err := jsonld.Marshal(GetExample()) that.NoError(err) fmt.Println(string(result)) fmt.Println() another := ap.Object{} err = jsonld.Unmarshal(result, &another) that.NoError(err) fmt.Printf("%+v\n", another) }