Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Setting Json Serializer Settings #932

Closed
adriaanp opened this issue Aug 4, 2014 · 3 comments
Closed

Setting Json Serializer Settings #932

adriaanp opened this issue Aug 4, 2014 · 3 comments

Comments

@adriaanp
Copy link

adriaanp commented Aug 4, 2014

How would we change serializer settings for the json serializer?

@yishaigalatzer
Copy link
Contributor

There are a few ways to get json out of MVC.

  1. Return a JsonResult. If you do that just set the JsonSettings property with your settings.
    https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Core/ActionResults/JsonResult.cs
  2. Return an object and let content negotiation take it's place. In that case you want to access the JsonOutputFormatter from MvcOptions and replace it with a new one constructed with SerializerSettings.

https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Core/ActionResults/JsonResult.cs

@yishaigalatzer
Copy link
Contributor

@harshgMSFT we should also expose the serializersettings on the formatter as a property. It will make it much more discoverable and easier to change by user.

@yishaigalatzer
Copy link
Contributor

also cover the scenario is #1215 (so both input/output formatters gets the settings and default settings static method).

kichalla added a commit that referenced this issue Oct 10, 2014
…izer settings

[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
kichalla added a commit that referenced this issue Oct 10, 2014
…izer settings

[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
kichalla added a commit that referenced this issue Oct 10, 2014
…izer settings

[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
kichalla added a commit that referenced this issue Oct 10, 2014
…izer settings

[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
kichalla added a commit that referenced this issue Oct 14, 2014
…izer settings

[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
kichalla added a commit that referenced this issue Oct 15, 2014
…izer settings

[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants