go-ipld-prime icon indicating copy to clipboard operation
go-ipld-prime copied to clipboard

Encoding and subsequent decoding of an ipld schema'd struct needs to work

Open willscott opened this issue 3 years ago • 2 comments

Suppose you have a struct define as

	ts.Accumulate(schema.SpawnStruct("Example", []schema.StructField{
		schema.SpawnStructField("Optional", "String", true, false),
	}, schema.SpawnStructRepresentationMap(map[string]string{})))

and you serialize it:

node := _Example {
  Optional: _String__Maybe{v:schema.Maybe_Abscent}
}
linkPrototype.Build(ctx, ipld.LinkContext{}, node, storer)

This will serialize (with the link prototype being dagjson) to

{
  "Optional": null
}

which.. is wrong?

on attempting to decode it, it will then fail.

willscott avatar Jun 08 '21 20:06 willscott