| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
A System.Text.Json serialization provider for the UUID library.
dotnet add package UUID.Serialization.Systemusing System.Text.Json;
// Register the converter globally
JsonSerializerOptions options = new()
{
Converters = { new UUIDConverter() }
};
// Serialize
var uuid = new UUID();
string json = JsonSerializer.Serialize(uuid, options);
// Deserialize
UUID deserializedUuid = JsonSerializer.Deserialize<UUID>(json, options);public class UserModel
{
public UUID Id { get; set; }
public string Name { get; set; }
}
// Register converter
JsonSerializerOptions options = new()
{
Converters = { new UUIDConverter() }
};
// Serialize model
var user = new UserModel
{
Id = new UUID(),
Name = "John Doe"
};
string json = JsonSerializer.Serialize(user, options);
// Deserialize model
UserModel deserializedUser = JsonSerializer.Deserialize<UserModel>(json, options);The converter provides detailed error messages for common scenarios:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License. See the LICENSE file in the root directory for more details.
| Back | FazBrowse Home | New Git URL |