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

Exclude $type information from some requests #6

Open
LeonardoHSilva opened this issue Sep 18, 2013 · 3 comments
Open

Exclude $type information from some requests #6

LeonardoHSilva opened this issue Sep 18, 2013 · 3 comments

Comments

@LeonardoHSilva
Copy link

Hi John.

I've been using your framework in the last two months and I think it is great. One thing that I would like to improve is to serialize type information only when it is needed instead of serializing it in all requests.

As an exemple, in your demo App I think the request http://durandaldemo.apphb.com/api/color from the edit survey page is just used to fill the combobox. So in this case bringing type information from the server is just pure overhead.

I would like to hear your opinion on how to overcome this performance overhead.

Thanks,
Best regards.
Leonardo Silva.

@johnculviner
Copy link
Owner

Hey Leonardo,

I believe if you add an [ExcludeMetadata] attribute to the endpoint "action" or controller you wish to exclude it will do what you are looking for. Sorry that part isn't very well documented or demoed. Let me know!

John

@LeonardoHSilva
Copy link
Author

Hi John.

ExcludeMetadata attribute class is not what I'm looking for. I'm talking about the serialization made by JsonSerializer. Your framework requires that JsonSerializer settings has the following property set:

settings.TypeNameHandling = TypeNameHandling.Objects;

This will add TypeName information to every object serialized to Json. For performance reasons I don't want to include type name in every object serialized to json. Do you know how I can avoid this for some classes?

As an exemple, in your demo App I think the request http://durandaldemo.apphb.com/api/color from the edit survey page is just used to fill the combobox. So in this case bringing type information from the server is just pure overhead.

Thanks,
Leonardo.

@johnculviner
Copy link
Owner

Hey Leonardo,

Ahh I see what you are saying now. Yeah that:

settings.TypeNameHandling = TypeNameHandling.Objects

is an all or nothing deal via JSON.NET I believe. It might be possible to define your own ContractResolver to include/exclude via an attribute in JSON.NET as it is very extensible but I haven't experimented with it yet.

Sorry I don't have a better solution unfortunately!

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

No branches or pull requests

2 participants