https://github.com/kris701/serializablehttps
A project to make it easier to serialise and deserialise HTTP requests and responses
https://github.com/kris701/serializablehttps
csharp https serialization
Last synced: 6 months ago
JSON representation
A project to make it easier to serialise and deserialise HTTP requests and responses
- Host: GitHub
- URL: https://github.com/kris701/serializablehttps
- Owner: kris701
- License: mit
- Created: 2024-08-21T16:42:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-29T08:52:52.000Z (over 1 year ago)
- Last Synced: 2024-08-30T09:15:38.484Z (over 1 year ago)
- Topics: csharp, https, serialization
- Language: C#
- Homepage:
- Size: 39.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://github.com/kris701/SerializableHttps/actions/workflows/dotnet-desktop.yml)







# SerializableHttps
This is a project to make it easier to work with the `HttpClient` in C#.
The idea is that instead of manually serialising and deserialising json content, you can just let this library do it for you!
In its most simple form, a HTTP call can be made as follows:
```csharp
var input = new InputModel(){
Value = 34512,
Name = "something"
};
var client = new SerializableHttpsClient();
var result = client.Post(input, "https://localhost/test");
```
The library will then automatically serialise the input model correctly, and deserialise the response into the `OutputModel`;
Usually, all the body serialisation is in JSON format, however you can also give it a `XElement` as an input or output and it will serialise/deserialise as XML instead of JSON.
You can also use it to transfer file streams. There is a base model for file streaming, called `FileDataModel`, where a stream can be set to it.
The library will then serialise and deserialise it as a stream instead of a JSON document.
The serialisation used depends on the call, i.e. if its a POST, PATCH, GET or DELETE:
* DELETE and GET: Serialises the input model as a query string in the URL.
* POST and PATCH: Serialises the input model as JSON.
For this system to work, all the input and output models must be serialisable (i.e. no `dynamic` or `object`!)
You can find the project as a package on the [NuGet Package Manager](https://www.nuget.org/packages/SerializableHttps/).