PseudoJsonParser 1.0.0

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

PseudoJsonParser

一个简单而强大的.NET库,用于将JSON格式字符串解析为C#字典表达式,支持具体值和变量表达式。

特性

  • 支持解析JSON到Dictionary<string, object>
  • 支持基本数据类型(字符串、数字、布尔值、null)
  • 支持变量表达式(以$开头的字符串)
  • 支持嵌套对象和数组
  • 完整的异常处理

安装

dotnet add package PseudoJsonParser

使用示例

using PseudoJsonParser;

// 基本使用
var json = @"{
    ""name"": ""John"",
    ""age"": 30,
    ""isActive"": true,
    ""variable"": ""$userId""
}";

var result = JsonExpressionParser.Parse(json);

// 访问具体值
string name = (string)result["name"]; // "John"
decimal age = (decimal)result["age"]; // 30
bool isActive = (bool)result["isActive"]; // true

// 访问变量表达式
var userIdVar = (VariableExpression)result["variable"];
string varName = userIdVar.Name; // "userId"

// 处理嵌套对象
var complexJson = @"{
    ""user"": {
        ""id"": ""$currentUserId"",
        ""settings"": {
            ""theme"": ""dark"",
            ""language"": ""$userLanguage""
        }
    }
}";

var complexResult = JsonExpressionParser.Parse(complexJson);

异常处理

try
{
    var result = JsonExpressionParser.Parse(jsonString);
}
catch (JsonParsingException ex)
{
    // 处理解析错误
    Console.WriteLine($"解析错误: {ex.Message}");
}

许可证

本项目采用MIT许可证。详见LICENSE文件。

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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.0.0 192 4/5/2025