Skip to content

Serialize IEnumerable as embeded issue #48

Description

@xotahal

I have problem if class has property ICollection<SomeClass> foo and this property has attribute [SerializeAs(SerializeAsOptions.Embedded)]. There is switch with case SerializeAsOptions.Embedded in JsonApiFormatter.Serialize(..).

That case contains:
this.Serialize(prop.GetValue(value, null), writeStream, writer, serializer, aggregator);

But property should be serialized as many.

There could be something like that:

var propValue = prop.GetValue(value, null);

if (_modelManager.IsSerializedAsMany(propValue.GetType()))
    this.SerializeMany(propValue, writeStream, writer, serializer, aggregator);
else
    this.Serialize(propValue, writeStream, writer, serializer, aggregator);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions