MessagePack for C# (.NET, .NET Core, Unity, Xamarin)
JsonSubTypes
Our great sponsors
MessagePack for C# (.NET, .NET Core, Unity, Xamarin) | JsonSubTypes | |
---|---|---|
19 | 4 | |
5,245 | 389 | |
1.9% | - | |
6.8 | 3.4 | |
6 days ago | 17 days ago | |
C# | C# | |
GNU General Public License v3.0 or later | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
MessagePack for C# (.NET, .NET Core, Unity, Xamarin)
- .NET 9 will be putting BinaryFormatter out to pasture
-
Fury: 170x faster than JDK, fast serialization powered by JIT and Zero-copy
Given it's a binary serialization framework, it should not be too difficult, because the domain is well-explored and numerous libraries exist in C# which address same goals that Fury does.
More popular/newer examples are https://github.com/Cysharp/MemoryPack (which is similar to Fury with its own spec, C#-code first schema), https://github.com/MessagePack-CSharp/MessagePack-CSharp or even gRPC / Protobuf tooling https://github.com/grpc/grpc-dotnet
-
Native AOT Overview
With Unity/IL2CPP stuff: For general-purpose serialization libraries like JSON, you sometimes need to provide hints to make sure types are included: https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Fi...
For schema serialization on known types, there are codegen tools (i.e. moc for MessagePack): https://github.com/neuecc/MessagePack-CSharp
MessagePack is migrating to Rosalyn code generators, so basically invisible codegen. Cysharp's newer serialization library, MessagePack, already uses this: https://github.com/Cysharp/MemoryPack
-
Dupes in bonelab?
Thanks, I'm sure I'll need it, though I do have my own platform with serialization set up already that I'm hoping I can port relatively easily (It's backended with MessagePack C# which is a lovely serializer for Unity.)
-
Does MessagePack-CSharp support OneOf type?
In the Road map of features #119 for MessagePack-CSharp, they checked the box for:
-
Dotnet API super slow?
Try MessagePack for serialization. It will help to reduce the size of the message and the time of serialization.
- Need persistent data across runs of your Unity game? Don't use PlayerPrefs for your game state! Here's how you can easily store your arbitrary game state in files instead.
-
Practice resources for handling and optimizing large game data sets?
I mentioned JSON, but there are many formats that are much more efficient. I can mention FlatBuffers, MessagePack and ProtoBuf. These are the ones I've used myself, and personally I'm most comfortable with MessagePack and ProtoBuf. I don't think the performance would be an issue if you had to choose between these three, it's mostly the API that is different.
- any good binary serializers that are not assembly dependent
-
LIVE: Otimizando aplicações .NET com MessagePack.
Biblioteca Nuget para C#
JsonSubTypes
- .Net 6 - Rest Api is deserializing property of "object" type to JsonElement type (System.Text.Json)
-
An API receives different message types
If messages are arriving as Json you can use JsonSubTypes to deserialize to different DTOs based on the UUIDs (https://github.com/manuc66/JsonSubTypes) and then use the visitor pattern to dispatch the DTOs to the correct method.
-
What is your preferred way of creating application specific files for a local application?
Personally I've had good success with JsonSubTypes for deserializing discriminated unions from JSON. It'll serialize stuff into the right type, and then you just need a switch statement to typecast it afterwards.
-
How to create a data-driven software product that indicates pre-coded functionality?
There is a small use case that I consider valid for this. It would be for determining a set of pre-defined behaviors to make available to definitions of entities in a game. And the json data would not be coming from external sources, it would be tightly controlled by me as the developer. The response you made to the other comment on my post shared a link that said the practice shouldn't be done with untrusted data, and there would be no untrusted data since there'd be no external data. The article also mentions to restrict the types that can be deserialized, and that is definitely possible. The architecture pattern for this is ECS (Entity Component System) and the data-drive portion might have been a mis-naming of my post, it's more of a lot of the design of entities and components is stored in data files, and there are a few cases where I will want to associate certain functionality in the code with these data entity definitions. No operating system level functionality would be exposed. I've even been referred to a library available via nuget that will allow for what I'm attempting to do: https://github.com/manuc66/JsonSubTypes
What are some alternatives?
Json.NET - Json.NET is a popular high-performance JSON framework for .NET
Protobuf.NET - Protocol Buffers library for idiomatic .NET
JsonKnownTypes - Simple way to serialize and deserialize polymorphic types for Json.NET
Protobuf - Protocol Buffers - Google's data interchange format
Utf8Json - Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
ZeroFormatter - Infinitely Fast Deserializer for .NET, .NET Core and Unity.
Wire - Binary serializer for POCO objects
Msgpack-Cli - MessagePack implementation for Common Language Infrastructure / msgpack.org[C#]
FlatSharp - Fast, idiomatic C# implementation of Flatbuffers
Bois - Salar.Bois is a compact, fast and powerful binary serializer for .NET Framework. With Bois you can serialize your existing objects with almost no change.