JsonhCs 3.9.0

dotnet add package JsonhCs --version 3.9.0
                    
NuGet\Install-Package JsonhCs -Version 3.9.0
                    
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="JsonhCs" Version="3.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JsonhCs" Version="3.9.0" />
                    
Directory.Packages.props
<PackageReference Include="JsonhCs" />
                    
Project file
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 JsonhCs --version 3.9.0
                    
#r "nuget: JsonhCs, 3.9.0"
                    
#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 JsonhCs@3.9.0
                    
#: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=JsonhCs&version=3.9.0
                    
Install as a Cake Addin
#tool nuget:?package=JsonhCs&version=3.9.0
                    
Install as a Cake Tool

<img src="https://github.com/jsonh-org/Jsonh/blob/main/IconUpscaled.png?raw=true" width=180>

NuGet

JSON for Humans.

JSON is great. Until you miss that trailing comma... or want to use comments. What about multiline strings? JSONH provides a much more elegant way to write JSON that's designed for humans rather than machines.

Since JSONH is compatible with JSON, any JSONH syntax can be represented with equivalent JSON.

JsonhCs

JsonhCs is a parser implementation of JSONH v1 for C# .NET.

Example

{
    // use #, // or /**/ comments
    
    // quotes are optional
    keys: without quotes,

    // commas are optional
    isn\'t: {
        that: cool? # yes
    }

    // use multiline strings
    haiku: '''
        Let me die in spring
          beneath the cherry blossoms
            while the moon is full.
        '''
    
    // compatible with JSON5
    key: 0xDEADCAFE

    // or use JSON
    "old school": 1337
}

Usage

Everything you need is contained within JsonhReader:

string Jsonh = """
    {
        this is: awesome
    }
    """;
string Element = JsonhCs.JsonhReader.ParseElement<string>(Jsonh).Value!;

Source Generation

If using NativeAOT, you will need to use the JsonNode APIs:

public class Player {
    public required string Name { get; set; }
    public required int Health { get; set; }
}

[JsonSourceGenerationOptions]
[JsonSerializable(typeof(Player))]
internal partial class PlayerContext : JsonSerializerContext {
}
string PlayerJsonh = """
    Name: John Doe
    Health: 9_999_999
    """;
Player PlayerObject = JsonhCs.JsonhReader.ParseNode(PlayerJsonh).Value
    .Deserialize(PlayerContext.Default.Player)!;
Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on JsonhCs:

Package Downloads
SystemCall

A command-parsing library inspired by Jinx.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.9.0 435 7/24/2025
3.8.0 182 6/26/2025
3.7.0 147 6/16/2025
3.6.0 182 6/5/2025
3.5.0 88 5/31/2025
3.4.0 299 5/23/2025
3.3.0 149 5/19/2025
3.2.0 163 4/29/2025
3.1.0 194 4/17/2025
3.0.0 195 4/14/2025
2.0.0 170 4/11/2025
1.4.0 124 3/29/2025
1.3.0 470 3/25/2025
1.2.0 157 3/20/2025
1.1.0 159 3/19/2025
1.0.0 152 3/19/2025