Astn/JSON-RPC.NET

Configurable JSON serialization/deserialization

hovi opened this issue · 5 comments

hovi commented

Is there way to configure the serializer? I see this library is using newtonjson.
In my case I'd like to set NullValueHandling = NullValueHandling.Ignore for data response objects.

Astn commented

Off the top of my head, I think anything you annotate on your own models works.
There may be a serializer settings you can access. If not then we should add one.

Astn commented

I just looked, and it's not exposed yet in the main branch.

hovi commented

If you give me a lead, I might try to make a PR. C# is not my strong language though.

Astn commented

@hovi Sure thing.
The main place to start would be in JsonRpcProcessor.cs
Fuctions Process wrap calls to ProcessInternal. Those would be where you would add the JsonSerializerSettings optional parameter.

image

Then there are a handfull of places the method could return if there are errors, so any call to JsonConvert.SerializeObject would be where the JsonSerializerSettings get passed.

image

Astn commented

This is published it to nuget as of version 1.2.3 @ 177be60