
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
SerialBox is a simple serialization wrapper. It acts as a wrapper around various serialization libraries, thus giving them a common interface to deal with.
SerialBox is a library designed to simplify serialization in .Net. By default it supports XML and JSON but can be expanded upon to support other serialization targets as well.
The library can be initialized by registering it with your IoC container during startup. Example code:
ServiceProvider? ServiceProvider = new ServiceCollection().RegisterSerialBox()?.BuildServiceProvider();
or
ServiceProvider? ServiceProvider = new ServiceCollection().AddCanisterModules()?.BuildServiceProvider();
As the library supports Canister Modules.
This line is required prior to using the extension methods for the first time. Once it is set up, you can call the extension methods provided:
[DataContract]
public class Temp
{
[DataMember(Name = "A", Order = 1)]
public int A { get; set; }
}
...
var TestObj = new Temp() { A = 100 };
string Value = TestObj.Serialize<string, Temp>();
Temp TestObj2 = Value.Deserialize<Temp, string>();
The Serialize function takes the serialization type as a parameter. If one is not passed in, it defaults to JSON. This parameter can either be the MIME type for the serialization type as a string or it can be a SerializationType object. The Deserialize function acts in the same manner.
The system comes with JSON and XML serialization, however you may wish to add other targets such as binary. In order to do this all that you need to do is create a class that inherits from ISerializer:
public class MySerializer : ISerializer<byte[]>
{
public string ContentType => "application/octet-stream";
public string FileType => ".blob";
public string Name => "Binary";
public object Deserialize(Type objectType, byte[] data) { ... }
public byte[] Serialize(Type objectType, object data) { ... }
}
After the class is created, the system will automatically pick it up and use it.
By default the system uses the built in JSON and XML providers in .Net. However it is possible to override these by simply creating a class that inherits from ISerializer and setting the correct ContentType to match the one that you wish to override. For instance to override the JSON provider with your own you would do the following:
public class MySerializer : ISerializer<string>
{
public string ContentType => "application/json";
public string FileType => ".json";
public string Name => "JSON";
public object Deserialize(Type objectType, string data) { ... }
public string Serialize(Type objectType, object data) { ... }
}
After the class is created, the system will automatically pick it up and use it.
The library is available via Nuget with the package name "SerialBox". To install it run the following command in the Package Manager Console:
Install-Package SerialBox
In order to build the library you will require the following as a minimum:
Other than that, just clone the project and you should be able to load the solution and build without too much effort.
FAQs
SerialBox is a simple serialization wrapper. It acts as a wrapper around various serialization libraries, thus giving them a common interface to deal with.
We found that serialbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.