Jyson 1.1.19652
dotnet add package Jyson --version 1.1.19652
NuGet\Install-Package Jyson -Version 1.1.19652
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jyson" Version="1.1.19652" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jyson" Version="1.1.19652" />
<PackageReference Include="Jyson" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jyson --version 1.1.19652
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jyson, 1.1.19652"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Jyson@1.1.19652
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jyson&version=1.1.19652
#tool nuget:?package=Jyson&version=1.1.19652
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jyson
Jyson is a Python-like JSON library for C#, making JSON parsing and manipulation as elegant and intuitive as Python while preserving the power of C# and LINQ.
Features
- Python-style API: Familiar methods like
loads(),load(),dumps(), anddump() - Dynamic access: Navigate JSON with dot notation (
data.person.nameinstead ofdata["person"]["name"]) - Dictionary-like methods: Python-esque dictionary methods like
Get()with default values - LINQ integration: Convert JSON arrays to typed collections for powerful LINQ queries
- Deep nesting support: Handles complex nested JSON structures with ease
- Type conversion helpers: Safely convert between JSON types and C# types
Installation
Install via .NET CLI:
dotnet add package Jyson
Quick Start
using Archsoft.Json;
// Parse JSON string
string jsonString = @"{""name"":""John"",""age"":30,""hobbies"":[""reading"",""travel""]}";
dynamic data = Jyson.Loads(jsonString);
// Access properties with dot notation
Console.WriteLine($"Name: {data.name}"); // "John"
Console.WriteLine($"Age: {data.age}"); // 30
// Access arrays
foreach (var hobby in (List<object>)data.hobbies)
{
Console.WriteLine($"Hobby: {hobby}");
}
// Dictionary-like methods
var dataDict = data as IDictionary<string, object>;
bool hasAddress = dataDict.Contains("address"); // false
string country = dataDict.Get("country", "USA").ToString(); // "USA" (default value)
// Create and serialize objects
var person = new { Name = "Jane", Age = 28 };
string json = Jyson.Dumps(person);
Jyson.Dump(person, "person.json");
LINQ Integration
string jsonString = @"{
""people"": [
{""name"": ""Alice"", ""age"": 25, ""active"": true},
{""name"": ""Bob"", ""age"": 32, ""active"": false},
{""name"": ""Charlie"", ""age"": 28, ""active"": true}
]
}";
dynamic data = Jyson.Loads(jsonString);
var peopleArray = data.people as List<object>;
// Use LINQ with automatic type conversion
var activeUsers = peopleArray.AsEnumerable<dynamic>()
.Where(p => p.active == true)
.Select(p => p.name)
.ToList();
// Using type-specific collections
var ages = peopleArray.AsEnumerable<dynamic>()
.Select(p => (int)p.age)
.ToList();
double averageAge = ages.Average();
Complex Nested JSON
Jyson handles deeply nested structures with ease:
string jsonString = @"{
""organization"": {
""name"": ""Acme Inc"",
""departments"": [
{
""name"": ""Engineering"",
""teams"": [
{
""name"": ""Backend"",
""members"": [
{""name"": ""Alice"", ""role"": ""Developer""},
{""name"": ""Bob"", ""role"": ""Team Lead""}
]
}
]
}
]
}
}";
dynamic data = Jyson.Loads(jsonString);
// Access deep nested properties with dot notation
string companyName = data.organization.name;
string teamName = data.organization.departments[0].teams[0].name;
string firstMemberRole = data.organization.departments[0].teams[0].members[0].role;
// LINQ query with nested data
var engineers = ((List<object>)data.organization.departments[0].teams[0].members)
.AsEnumerable<dynamic>()
.Where(m => m.role == "Developer")
.Select(m => m.name)
.ToList();
Dictionary Methods
// Get with default value (like Python's dict.get)
dynamic data = Jyson.Loads(@"{""user"":{""name"":""John""}}");
var userDict = data.user as IDictionary<string, object>;
string name = userDict.Get("name", "Unknown").ToString(); // "John"
string email = userDict.Get("email", "none@example.com").ToString(); // "none@example.com"
// Check if key exists (like Python's "key in dict")
bool hasName = userDict.Contains("name"); // true
bool hasAddress = userDict.Contains("address"); // false
Advanced Usage
Custom Type Conversion
// Convert JSON array to a typed list
dynamic data = Jyson.Loads(@"{""scores"":[95,87,92]}");
var scores = (data.scores as List<object>).AsList<int>();
// Convert a JSON object to a Dictionary
dynamic settings = Jyson.Loads(@"{""timeout"":30,""retries"":3}");
var settingsDict = (settings as IDictionary<string, object>).AsDictionary<int>();
File Operations
// Load from file
dynamic config = Jyson.Load("config.json");
// Save to file
var settings = new { ApiKey = "abc123", Timeout = 30 };
Jyson.Dump(settings, "settings.json", indent: true);
Compatibility
Jyson works with:
- .NET 7.0 or later
| 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 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
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.1.19652 | 230 | 3/31/2025 |