Net.Web3.EthereumWallet.Json
1.2.1
See the version list below for details.
dotnet add package Net.Web3.EthereumWallet.Json --version 1.2.1
NuGet\Install-Package Net.Web3.EthereumWallet.Json -Version 1.2.1
<PackageReference Include="Net.Web3.EthereumWallet.Json" Version="1.2.1" />
<PackageVersion Include="Net.Web3.EthereumWallet.Json" Version="1.2.1" />
<PackageReference Include="Net.Web3.EthereumWallet.Json" />
paket add Net.Web3.EthereumWallet.Json --version 1.2.1
#r "nuget: Net.Web3.EthereumWallet.Json, 1.2.1"
#:package Net.Web3.EthereumWallet.Json@1.2.1
#addin nuget:?package=Net.Web3.EthereumWallet.Json&version=1.2.1
#tool nuget:?package=Net.Web3.EthereumWallet.Json&version=1.2.1
Net.Web3.EthereumWallet.Json
Description
Net.Web3.EthereumWallet.Json is a C# library that adds a Newtonsoft.Json converter for the EthereumAddress class from the Net.Web3.EthereumWallet library.
Installation
You can install the package via NuGet:
Install-Package Net.Web3.EthereumWallet.Json
Or using .NET CLI:
dotnet add package Net.Web3.EthereumWallet.Json
Usage
To use the Net.Web3.EthereumWallet.Json converter, you need to configure Newtonsoft.Json to recognize and handle the EthereumAddress type.
Below are examples demonstrating how to serialize and deserialize objects containing EthereumAddress properties.
Example Scenario
Suppose you have a User class that includes an EthereumAddress property:
using Newtonsoft.Json;
using Net.Web3.EthereumWallet;
public class User
{
public string Name { get; set; }
[JsonConverter(typeof(Net.Web3.EthereumWallet.Json.Converters.EthereumAddressConverter))]
public EthereumAddress Address { get; set; }
}
Serialization
To serialize a User object to JSON, ensuring that the EthereumAddress is properly converted to a string:
using System;
using Newtonsoft.Json;
using Net.Web3.EthereumWallet;
using Net.Web3.EthereumWallet.Json.Converters;
public class Program
{
public static void Main()
{
var user = new User
{
Name = "Alice",
Address = "0x1234567890abcdef1234567890abcdef12345678"
};
string json = JsonConvert.SerializeObject(user, Formatting.Indented);
Console.WriteLine(json);
}
}
Output:
{
"Name": "Alice",
"Address": "0x1234567890abcdef1234567890abcdef12345678"
}
Deserialization
To deserialize JSON back into a User object, ensuring that the Address string is correctly converted to an EthereumAddress instance:
using System;
using Newtonsoft.Json;
using Net.Web3.EthereumWallet;
using Net.Web3.EthereumWallet.Json.Converters;
public class Program
{
public static void Main()
{
var json = @"{
""Name"": ""Bob"",
""Address"": ""0xabcdefabcdefabcdefabcdefabcdefabcdefabcd""
}";
var user = JsonConvert.DeserializeObject<User>(json)!;
Console.WriteLine($"Deserialized UserName: {user.Name}");
Console.WriteLine($"Deserialized UserAddress: {user.Address.Address}");
}
}
Output:
Deserialized User Name: Bob
Deserialized User Address: 0xabcdefabcdefabcdefabcdefabcdefabcdefabcd
License
Net.Web3.EthereumWallet.Json is open-sourced software licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Net.Web3.EthereumWallet (>= 1.2.1)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.