Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize IEnumerable as embeded issue #48

Open
xotahal opened this issue Feb 4, 2015 · 2 comments
Open

Serialize IEnumerable as embeded issue #48

xotahal opened this issue Feb 4, 2015 · 2 comments
Labels
Milestone

Comments

@xotahal
Copy link

xotahal commented Feb 4, 2015

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);
@SphtKr SphtKr added this to the 0.4.0 milestone Feb 4, 2015
@SphtKr
Copy link
Collaborator

SphtKr commented Feb 4, 2015

Yes, unfortunately SerializeAsOptions.Embedded is not fully supported yet. I'm concerned about rushing this as it may introduce complications both for design and implementation (what about recursion? what about _de_serializing?), but we can tag this for 0.4.0 and see if it fits.

@SphtKr SphtKr added the bug label Feb 4, 2015
@SphtKr
Copy link
Collaborator

SphtKr commented Feb 4, 2015

I'm calling this a bug for now, but it may get rolled into a larger enhancement to complete implementation of SerializeAs.Embedded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants