Sealkeen.CSCourse2016.JSONParser.Core
1.0.2
dotnet add package Sealkeen.CSCourse2016.JSONParser.Core --version 1.0.2
NuGet\Install-Package Sealkeen.CSCourse2016.JSONParser.Core -Version 1.0.2
<PackageReference Include="Sealkeen.CSCourse2016.JSONParser.Core" Version="1.0.2" />
paket add Sealkeen.CSCourse2016.JSONParser.Core --version 1.0.2
#r "nuget: Sealkeen.CSCourse2016.JSONParser.Core, 1.0.2"
// Install Sealkeen.CSCourse2016.JSONParser.Core as a Cake Addin
#addin nuget:?package=Sealkeen.CSCourse2016.JSONParser.Core&version=1.0.2
// Install Sealkeen.CSCourse2016.JSONParser.Core as a Cake Tool
#tool nuget:?package=Sealkeen.CSCourse2016.JSONParser.Core&version=1.0.2
Overview
Linq-to-XML styled project to create static-typed JSON Objects, e.g. - JString and JSingleValue for ("string" and 45).
Test case. Reading from appSettings.Development.json.
[Test]
public void ParseTest()
{
JSONParser jSONParser = new JSONParser("O:\\VCSharp\\MediaStreamer.Web\\AuthMVCApplication\\appsettings.Development.json");
var jItem = jSONParser.Parse();
var logLevel = jItem.FindPairByKey(new JString("LogLevel"));
var defaultLogLevel = logLevel.FindPairByKey(new JString("Default"));
Debug.WriteLine(jItem);
// {"Logging":{"LogLevel":{"Default":"Information","Microsoft":"Warning","Microsoft.Hosting.Lifetime":"Information"}}}
Debug.WriteLine(logLevel);
// "LogLevel":{"Default":"Information","Microsoft":"Warning","Microsoft.Hosting.Lifetime":"Information"}
Debug.WriteLine(logLevel.Value);
// {"Default":"Information","Microsoft":"Warning","Microsoft.Hosting.Lifetime":"Information"}
Debug.WriteLine(defaultLogLevel);
// "Default":"Information"
Debug.WriteLine(defaultLogLevel.Value);
// "Information"
}
Test case. Writing.
[Fact] // for XUnit [Test] //For NUnit
public void CreateAndOpenJObjectFile()
{
// No parent element so first parameter is null
JObject jObject = new JObject(null,
new JKeyValuePair(
new JString("Key"), new JString("Value")
)
);
jObject.SaveToFileAndOpenInNotepad("jKeyValuePair.txt");
}
// Result in "jKeyValuePair.txt"
// {"Key":"Value"}
Usage - output:
You can output the created objects using public methods like JItem.ToString() and JItem.ToFile("filename.txt"). See unit-tests for more info.
Usage - JSONParser class
Create a JSONParser class by calling Constructor (string filename)
Create a JSONParser class by calling Constructor (string[] JSONString) ** first element[0] of JSONString represents the in-memory JSONString that the parser will parse through. The next step is the in-memory objects represented :
public abstract class JItem
public abstract class JCollection
JKeyValuePair class = "key" : "value" // (JKeyValuePair): JCollection
JSingleValue = false || true || 1234 || 194.0 // (JSingleValue) : JItem (bool, integer, double, string)
JString = "JString object" || "any string value" // (JString) : (JSingleValue)
JObject = // (JObject) : JCollection *{ "JString" : true } || *{ { "JObject" }, { true }, { "JString" } } || *{ "Key" : "Value" } // JObject : JItem
JArray = [ { "JString" }, { "JObject" }, [ "JArray" ] ] // (JArray) : JCollection
Product | Versions 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. 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. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- 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.2 | 137 | 8/24/2023 |
1.0.1-beta | 110 | 4/15/2023 |
1.0.0 | 215 | 6/11/2022 |