TP.JsonFormat 1.0.9

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

[TOC]

json组件
一、使用
本功能插件使用了非静态类,所以使用的时候需要创建类对象
  • 在管理nuget程序包界面搜索,TP.JsonFormat,选择最新版本安装

  • 直接创建对象

    JsonObject jb = new JsonObject(jsonStr); // jsonStr 为指定的Json字符串
    

    来使用

二、功能
  1. class JsonObject 通过创建对象来解析对象

    首先创建一个JSON 字符串 如下
          	{
                "aa":"qwer",
                "bb":true,
                "cc":[
                        {
                            "aa":1,
                            "bb":12
                        },
                        {
                            "aa":13,
                            "bb":6
                        },
                        {
                            "a a":19,
                            "bb":"  1  "
                        }
                ]
        	}
    
    如下为demo代码,一些基本的查询和操作
     		//创建JSON 对象
                JsonObject jb = new JsonObject(result);
                // 根据键获取值
                JsonObject tmp2 = jb["aa"];
                String value1 = tmp2.value; //qwer
                //或者
                String value2 = jb["aa"].value; //qwer
    
                // 根据键获取值 多级获取
                JsonObject tmp3 = jb["cc"];
                // 键值对中的数组取值使用数字字符串 索引从0 开始
                JsonObject tmp4 = tmp3["1"]; 
                String value3 = tmp4["aa"].value; //13
                //或者
                String value4 = jb["cc"]["1"]["aa"].value; //13
    
                // 根据键修改值 (大括号,或者中括号包裹的信息叫做层级,你要查询的键值对,距最外层有几个括号就事第几层级)
                //第一层级键值对修改,返回第一层级对象本身
                JsonObject tmp5 = jb["aa"].setValue("rewq");
                JsonObject tmp6 = tmp5["bb"].setValue(false);
                String json2 = tmp6.json;
                //或者等同于
                JsonObject tmp7 = jb["aa"].setValue("rewq")["bb"].setValue(false);
                String json3 = tmp7.json;
    
                //根据键修改值 多层级修改
                //先获取多层级对象  jb 是第一层级("{")tmp8 是第二层级("[") tmp9 是第三层级("{")
                JsonObject tmp8 = jb["cc"];
                JsonObject tmp9 = tmp8["1"];
                JsonObject tmp10 = tmp9["aa"].setValue(100)["bb"].setValue(200);
                String json4 = tmp10.json;
                // 或者  
                JsonObject tmp11 = jb["cc"]["1"]["aa"].setValue(100)["bb"].setValue(200);
                String json5 = tmp11.json;
    
    以下为 json2 json3 json4 json5 的值
    {
    "aa":"rewq",
    "bb":false,
    "cc":[
    {
    "aa":1,
    "bb":12
    },
    {
    "aa":13,
    "bb":6
    },
    {
    "a a":19,
    "bb":"  1  "
    }
    ]
    }
    #-------------------
    {
    "aa":"rewq",
    "bb":false,
    "cc":[
    {
    "aa":1,
    "bb":12
    },
    {
    "aa":13,
    "bb":6
    },
    {
    "a a":19,
    "bb":"  1  "
    }
    ]
    }
    #-------------------
    {
    "aa":"qwer",
    "bb":true,
    "cc":[
    {
    "aa":1,
    "bb":12
    },
    {
    "aa":100,
    "bb":200
    },
    {
    "a a":19,
    "bb":"  1  "
    }
    ]
    }
    #-------------------
    {
    "aa":"qwer",
    "bb":true,
    "cc":[
    {
    "aa":1,
    "bb":12
    },
    {
    "aa":100,
    "bb":200
    },
    {
    "a a":19,
    "bb":"  1  "
    }
    ]
    }
    
    • 方法:int getArrCounts() 返回当前阶层(如为数组,中包含的数组对象)
  2. ObjectToJson 将数据,集合,对象类型的东西转化为JSON字符串

    • 方法:String ConvertDicJson(Dictionary<String ,Object> dic) <u>将传入的 Dictionary 转化为JSON 字符串</u>
    • 方法: String dataTableToJson(DataTable dt) <u>将DataTable 转化为 JSON 字符串</u>
  3. JsonFileReader 读取JSON 文件

    • 方法:String ReadTxtContent(string Path) <u>读取txt文件内容</u>
  4. JsonFileWriter 将json对象存储到文件中

    • 方法:String writeJsonFile(String filePath,DataTable dt)<u>将DataTable 对象转化为JSON 并存储到指定文件中!</u>
      • filePath 将要存储的文件路径,无需文件存在
      • dt DataTable对象
三、同比增加

四、同比修改

五、同比修复

Product 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.  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. 
.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 was computed. 
.NET Framework 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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.9 516 12/24/2021
1.0.8 426 12/24/2021
1.0.7 418 12/24/2021
1.0.6 413 12/24/2021
1.0.5 411 12/24/2021
1.0.4 423 12/23/2021
1.0.3 429 12/18/2021
1.0.2 415 12/17/2021
1.0.1 465 11/11/2021