G9JSONHandler 2.0.0.4
See the version list below for details.
dotnet add package G9JSONHandler --version 2.0.0.4
NuGet\Install-Package G9JSONHandler -Version 2.0.0.4
<PackageReference Include="G9JSONHandler" Version="2.0.0.4" />
paket add G9JSONHandler --version 2.0.0.4
#r "nuget: G9JSONHandler, 2.0.0.4"
// Install G9JSONHandler as a Cake Addin #addin nuget:?package=G9JSONHandler&version=2.0.0.4 // Install G9JSONHandler as a Cake Tool #tool nuget:?package=G9JSONHandler&version=2.0.0.4
G9JSONHandler is a pretty small library for working with JSON.
Sample Object
using G9JSONHandler;
using G9JSONHandler.Attributes;
class TestObject
{
[G9AttrJsonComment("Custom JSON Comment")]
public string Name = ".NET";
public ConsoleColor Color = ConsoleColor.DarkMagenta;
[G9AttrJsonStoreEnumAsString]
public ConsoleColor Color2 = ConsoleColor.DarkGreen;
[G9AttrJsonCustomMemberName("MyRegisterDateTime")]
public DateTime RegisterDateTime = new(1990, 9, 1);
public TimeSpan Time = new(9, 9, 9);
public string[] Array = { "Item 1", "Item 2", "Item 3" };
public Dictionary<string, string> Dictionary = new()
{ { "Key 1", "Value 1" }, { "Key 2", "Value 2" }, { "Key 3", "Value 3" } };
[G9AttrJsonIgnoreMember]
public string Address = "...";
}
Object To JSON
TestObject testObject = new TestObject();
// Unformatted JSON
string unformattedJson = testObject.G9ObjectToJson();
// Formatted JSON
string formattedJson = testObject.G9ObjectToJson(true);
Result
// Unformatted JSON Result
{/* Custom JSON Comment */"Name":".NET","Color":5,"Color2":"DarkGreen","MyRegisterDateTime":"09/01/1990 00:00:00","Time":"09:09:09","Array":["Item 1","Item 2","Item 3"],"Dictionary":{"Key 1":"Value 1","Key 2":"Value 2","Key 3":"Value 3"}}
// Formatted JSON Result
{
/* Custom JSON Comment */
"Name":".NET",
"Color":5,
"Color2":"DarkGreen",
"MyRegisterDateTime":"09/01/1990 00:00:00",
"Time":"09:09:09",
"Array":
[
"Item 1",
"Item 2",
"Item 3"
],
"Dictionary":
{
"Key 1":"Value 1",
"Key 2":"Value 2",
"Key 3":"Value 3"
}
}
JSON To Object
// Object To JSON
// string formattedJson = testObject.G9ObjectToJson(true);
// JSON To Object
TestObject newObject = formattedJson.G9JsonToObject<TestObject>();
Console.WriteLine(newObject.Name); // .NET
Console.WriteLine(newObject.Color); // DarkMagenta
Console.WriteLine(newObject.Array.Length); // 3
Console.WriteLine(newObject.Dictionary.Count); // 3
Console.WriteLine(newObject.Dictionary["Key 2"]); // Value 2
Attributes
- G9AttrJsonComment
- This attribute enables you to write several comments (notes) for each item member in JSON.
- This attribute can use several times for an item member.
- This attribute enables you to write several comments (notes) for each item member in JSON.
- G9AttrJsonStoreEnumAsString
- This attribute enables you to store an Enum object as a string value in JSON (By default, an Enum object storing as a number).
- G9AttrJsonCustomMemberName
- This attribute enables you to choose a custom name for a member item for storing in JSON (At parsing time, the parser can recognize and pair the member item automatically).
- G9AttrJsonIgnoreMember
- This attribute enables you to ignore an item member for storing in JSON.
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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 is compatible. net452 is compatible. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.5.1
- No dependencies.
-
.NETFramework 4.5.2
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on G9JSONHandler:
Package | Downloads |
---|---|
G9ConfigManagement
Effective .NET library designed for working with and managing configs; has many useful features. This module provides a flexible framework that is pretty easy to use and straightforward. On the other hand, it has many functional attributes for making a tremendous and powerful config like BindabaleMember, Comment, Encryption, Required, Ordering, CustomName, Ignoring, CustomParser, etc. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.2 | 756 | 9/25/2022 |
3.0.1.1 | 702 | 9/23/2022 |
3.0.1 | 693 | 9/21/2022 |
3.0.0.1 | 409 | 9/21/2022 |
3.0.0 | 415 | 9/20/2022 |
2.0.5.5 | 404 | 9/11/2022 |
2.0.5.4 | 389 | 9/7/2022 |
2.0.5.3 | 389 | 8/31/2022 |
2.0.5.2 | 405 | 8/28/2022 |
2.0.5.1 | 386 | 8/28/2022 |
2.0.4.2 | 392 | 8/27/2022 |
2.0.3.1 | 402 | 8/25/2022 |
2.0.2 | 378 | 8/20/2022 |
2.0.1.3 | 407 | 8/18/2022 |
2.0.1.2 | 377 | 8/17/2022 |
2.0.1.1 | 387 | 8/17/2022 |
2.0.1 | 392 | 8/12/2022 |
2.0.0.5 | 395 | 8/11/2022 |
2.0.0.4 | 377 | 8/11/2022 |
2.0.0.3 | 385 | 8/11/2022 |
2.0.0.2 | 405 | 8/11/2022 |
2.0.0 | 401 | 8/10/2022 |
1.2.0 | 419 | 8/9/2022 |
1.0.0.1 | 413 | 8/8/2022 |
-- Fixed the problem with Enum while parsing to JSON as a number.
-- Added an efficient guide "Readme.md"
-- Fixed package (Source Link, Deterministic, Compiler Flags)
-- Completed tests