JsonPathSerializer 0.1.0-alpha
See the version list below for details.
dotnet add package JsonPathSerializer --version 0.1.0-alpha
NuGet\Install-Package JsonPathSerializer -Version 0.1.0-alpha
<PackageReference Include="JsonPathSerializer" Version="0.1.0-alpha" />
<PackageVersion Include="JsonPathSerializer" Version="0.1.0-alpha" />
<PackageReference Include="JsonPathSerializer" />
paket add JsonPathSerializer --version 0.1.0-alpha
#r "nuget: JsonPathSerializer, 0.1.0-alpha"
#:package JsonPathSerializer@0.1.0-alpha
#addin nuget:?package=JsonPathSerializer&version=0.1.0-alpha&prerelease
#tool nuget:?package=JsonPathSerializer&version=0.1.0-alpha&prerelease
JsonPathSerializer
Class library that helps putting data into the right place in a Json string, using JsonPath
Description
Built with .NET and newtonsoft.Json, JsonPathSerializer is a class library that aims to help automated tests and simulations to build large JSON objects using only values and their respective JSON path.
As of version 0.0.1.0, the project is more of a concept demo rather than a complete, deliverable .NET class library. See Constaints about known limitations of JsonPathSerializer.
Quick-demo
After building the project, reference the class library in your program and import it as using JsonPathSerializer;. You will also need the nuget Newtonsoft.Json.
Then, try the following code:
Dictionary<string, string> pathToValue = new Dictionary<string, string>()
{
{ "$.say.hello.world", "Hello world!" },
{ "$.say.hello.john", "Hello John!" },
{ "$.say.hi.jane", "Hi jane!" },
{ "$.say.hi.montreal[0]", "Salut Montr�al!" },
{ "$.say.hi.montreal[1]", "Hi Montreal!" },
};
JsonPathManager manager = new JsonPathManager();
foreach (var pair in pathToValue)
{
manager.Add(pair.Key, pair.Value);
}
Console.WriteLine(manager.Build());
Which gives: {"say":{"hello":{"world":"Hello world!","john":"Hello John!"},"hi":{"jane":"Hi jane!","montreal":["Salut Montr�al!","Hi Montreal!"]}}}, or:
{
"say": {
"hello": {
"world": "Hello world!",
"john": "Hello John!"
},
"hi": {
"jane": "Hi jane!",
"montreal": [
"Salut Montr�al!",
"Hi Montreal!"
]
}
}
}
Feature Summary
JsonPathSerializer supports JSON path in both dot and bracket notation, and currently support the following JSON path operation:
- Property, e.g.
$.foo.keyor['foo']['key'] - Index, e.g.
$.foo[1],$[-2] - Multiple indexes, e.g.
$.foo[1,2],$[-2, 3, 1]
JsonPathManager instance can be initialized with no argument (will create a new empty root), or with a JObject or JArray as its root.
Constaints
There are several important known issues and limitations for JsonPathSerializer for future development:
- Supports for JSON path operators will be gradually implemented.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. 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. |
-
net7.0
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 172 | 5/30/2024 |
| 0.3.0 | 185 | 1/29/2024 |
| 0.2.0 | 207 | 11/13/2023 |
| 0.1.2 | 133 | 9/26/2023 |
| 0.1.0-beta | 198 | 12/31/2022 |
| 0.1.0-alpha | 188 | 12/31/2022 |