You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
So we came across something odd today, we our json serialisation seemed to not work with RestSharp 106.6 (I think that is about what we are on), but deserialisation works. After some hunting around and trying to figure out what is wrong we came across RestSharps new ReadMe (as of Jan 1st) which pretty much says "Whops, Json.NET is coming back".
The juicy bits are as below.
Note on JSON serialization
Some time ago, we have decided to get rid of the reference to Newtonsoft.Json package.
The intentions were good, we thought that the SimpleJson library would be a good replacement that can be embedded to the library itself,
so we don't need to have any external references.
However, as many good intentions, that change created more issues than it solved. The number of issues on GitHub that are
related to JSON (de)serialization is growing and SimpleJson is long abandoned. We faced a choice to start maintaining SimpleJson ourselves or use something else.
Since as per today almost every .NET project has a direct or indirect reference to Newtonsoft.Json, we decided to bring it back as a dependency
and get rid of SimpleJson. This will be done in RestSharp v107, the next major version.
To prepare for this change, we made quite a few changes in how serialization works in RestSharp. Before, objects were serialized
when added to the RestRequest by using one of the AddBody methods. That made it impossible to assign a custom
serializer on the client level, so it should have been done for each request. In v106.6 body parameter is serialized just
before executing the request. Delaying the serialization allowed us to add the client-level serializer.
It is still possible to assign custom (de)serializer per request, as before. In addition to that, you can
use the new method IRestClient.UseSerializer(IRestSerializer restSerializer). The IRestSerializer interface
has methods for serialization and deserialization. Default serializers are the same as before.
From v106.6.2 you can use Newtonsoft.Json for the RestClient by using code from this snippet.
The text was updated successfully, but these errors were encountered:
So we came across something odd today, we our json serialisation seemed to not work with RestSharp 106.6 (I think that is about what we are on), but deserialisation works. After some hunting around and trying to figure out what is wrong we came across RestSharps new ReadMe (as of Jan 1st) which pretty much says "Whops, Json.NET is coming back".
The juicy bits are as below.
Note on JSON serialization
Some time ago, we have decided to get rid of the reference to
Newtonsoft.Json
package.The intentions were good, we thought that the
SimpleJson
library would be a good replacement that can be embedded to the library itself,so we don't need to have any external references.
However, as many good intentions, that change created more issues than it solved. The number of issues on GitHub that are
related to JSON (de)serialization is growing and
SimpleJson
is long abandoned. We faced a choice to start maintainingSimpleJson
ourselves or use something else.Since as per today almost every .NET project has a direct or indirect reference to
Newtonsoft.Json
, we decided to bring it back as a dependencyand get rid of
SimpleJson
. This will be done in RestSharp v107, the next major version.To prepare for this change, we made quite a few changes in how serialization works in RestSharp. Before, objects were serialized
when added to the
RestRequest
by using one of theAddBody
methods. That made it impossible to assign a customserializer on the client level, so it should have been done for each request. In v106.6 body parameter is serialized just
before executing the request. Delaying the serialization allowed us to add the client-level serializer.
It is still possible to assign custom (de)serializer per request, as before. In addition to that, you can
use the new method
IRestClient.UseSerializer(IRestSerializer restSerializer)
. TheIRestSerializer
interfacehas methods for serialization and deserialization. Default serializers are the same as before.
From v106.6.2 you can use
Newtonsoft.Json
for theRestClient
by using code from this snippet.The text was updated successfully, but these errors were encountered: