Xrm.Tools.CRMWebAPI icon indicating copy to clipboard operation
Xrm.Tools.CRMWebAPI copied to clipboard

Add support for JsonSerializationSettings

Open Cherepoc opened this issue 6 years ago • 6 comments

Hello! Currently there's no straightforward way to customize json serialization process for this package. Can you add it? Thank you!

Cherepoc avatar Mar 15 '18 19:03 Cherepoc

Can you elaborate on the scenario you are trying to solve?

davidyack avatar Mar 15 '18 19:03 davidyack

Shure! The crm project I'm working in has really badly named fields, and I want my dto objects to have nicer names. Also I want the dtos clients get using the library to serialize to json normally, so using JsonProperty or other standart attributes is out of the question. I figured out I could write custom attributes and contract resolver, but I need to supply that in serialization settings. Hope that makes sence. Thanks!

Cherepoc avatar Mar 16 '18 19:03 Cherepoc

ok I see, now I didn't look to hard at this, but take a look at http://blog.maskalik.com/asp-net/json-net-implement-custom-serialization/ - I believe Get<> and GetList<> would let you provide your own class, if you attribute it as this blog post indicated it looks like it would let your custom serializer do the work - disclaimer I didn't dig in too deep on the article - let me know if that gets you toward what you are trying to accomplish

davidyack avatar Mar 16 '18 20:03 davidyack

That won't do - it's the same as using JsonProperty attributes. I want to have a special kind of json serialization just for the crm, and let the classes work normally with other json serialization cases, but decorating property or a class with json attributes will apply them globally.

Cherepoc avatar Mar 16 '18 20:03 Cherepoc

So what changes to the API would you like to see?

davidyack avatar May 25 '18 14:05 davidyack

I think API-wise the best thing will be ability to set JsonSerializationSettings for CRMWebAPI object.

Cherepoc avatar Jul 15 '18 19:07 Cherepoc