PigJSonLib 1.1.0

Suggested Alternatives

PigToolsWinLib

There is a newer version of this package available.
See the version list below for details.
dotnet add package PigJSonLib --version 1.1.0
NuGet\Install-Package PigJSonLib -Version 1.1.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="PigJSonLib" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PigJSonLib --version 1.1.0
#r "nuget: PigJSonLib, 1.1.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.
// Install PigJSonLib as a Cake Addin
#addin nuget:?package=PigJSonLib&version=1.1.0

// Install PigJSonLib as a Cake Tool
#tool nuget:?package=PigJSonLib&version=1.1.0

PigJSon VB.net Sample code

Parse JSon Sample code

pjParse = New PigJSon("{""SayInf"":""Hello World""}")
If pjParse.LastErr = "" Then
	Debug.Print(pjParse.GetStrValue("SayInf"))
End If

Return results

Hello World

Simple text elements Sample code

pjAssemble = New PigJSon
With pjAssemble
	.AddEle("SiteName", "Seow Phong Web Site", True)    'The first element needs to be explicitly specified
	.AddEle("SiteUrl", "http://www.seowphong.com")  'The default is not the first element
	.AddEle("Describe", "A website for free software" & vbCrLf & " and shareware") 'The text contains a carriage return
	.AddSymbol(PigJSon.xpSymbolType.EleEndFlag)
	If .ParseJSON() = "OK" Then
		Debug.Print(.MainJSonStr)
		Debug.Print(.GetStrValue("SiteName"))
		Debug.Print(.GetStrValue("SiteUrl"))
		Debug.Print(.GetStrValue("Describe"))
	End If
End With

Return results

{"SiteName":"Seow Phong Web Site","SiteUrl":"http://www.seowphong.com","Describe":"A website for free software\r\n and shareware"}
Seow Phong Web Site
http://www.seowphong.com
A website for free software
 and shareware

Simple multiple data types elements Sample code

pjAssemble = New PigJSon
With pjAssemble
	.AddEle("SiteName", "Seow Phong Web Site", True)    'The first element needs to be explicitly specified
	.AddEle("SiteUrl", "http://www.seowphong.com")  'The default is not the first element
	.AddEle("Describe", "A website for free software" & vbCrLf & " and shareware") 'The text contains a carriage return
	.AddEle("Rank", 168)
	.AddEle("VisitPerDay", CDec(168.88))
	.AddEle("VisitTimeStr", "8/8/2020")
	.AddEle("VisitTime", Now)
	.AddEle("VisitTimeGT", Now, False, False)   'Global time
	.AddSymbol(PigJSon.xpSymbolType.EleEndFlag)
	If .ParseJSON() = "OK" Then
		Debug.Print(.MainJSonStr)
		Debug.Print(.GetStrValue("SiteName"))
		Debug.Print(.GetStrValue("SiteUrl"))
		Debug.Print(.GetStrValue("Describe"))
		Debug.Print(.GetIntValue("Rank").ToString)
		Debug.Print(.GetDecValue("VisitPerDay").ToString)
		Debug.Print(.GetStrValue("VisitTimeStr"))
		Debug.Print(.GetDateValue("VisitTime").ToString)
		Debug.Print(.GetDateValue("VisitTimeGT", False).ToString)
	End If
End With

Return results

{"SiteName":"Seow Phong Web Site","SiteUrl":"http://www.seowphong.com","Describe":"A website for free software\r\n and shareware","Rank":"168","VisitPerDay":"168.88","VisitTimeStr":"8/8/2020","VisitTime":"1601242412742","VisitTimeGT":"1601213612755"}
Seow Phong Web Site
http://www.seowphong.com
A website for free software
 and shareware
168
168.88
8/8/2020
2020/9/27 21:33:32
2020/9/27 13:33:32

Simple array elements Sample code

pjArray = New PigJSon
With pjArray
	'In this way, the content of the array element will be escaped.
	.AddEle("", "Google", True)
	.AddEle("", "GitHub")
	.AddEle("", "Apache")
End With
pjAssemble = New PigJSon
With pjAssemble
	.AddEle("TotalSites", 3, True)
	.AddOneArrayEle("SitesList", pjArray.MainJSonStr)
	.AddSymbol(PigJSon.xpSymbolType.EleEndFlag)
	If .ParseJSON() = "OK" Then
		Debug.Print(.MainJSonStr)
		Debug.Print(.GetIntValue("TotalSites").ToString)
		Debug.Print(.GetStrValue("SitesList[0]"))
		Debug.Print(.GetStrValue("SitesList[1]"))
		Debug.Print(.GetStrValue("SitesList[2]"))
	End If
End With

Return results

{"TotalSites":"3","SitesList":["Google","GitHub","Apache"]}
3
Google
GitHub
Apache

Return results

{"TotalSites":"3","SitesList":["Google","GitHub","Apache"]}
3
Google
GitHub
Apache

complex array elements Sample code

pjOneCompany = New PigJSon
pjArray = New PigJSon
pjAssemble = New PigJSon
With pjAssemble
	.AddEle("Name", "Company products", True)
	.AddArrayEleBegin("CompanyProductList")
	With pjArray
		.Reset()
		.AddEle("", "Windows", True)
		.AddEle("", "SQL Server")
		.AddEle("", "Office")
		.AddEle("", "Azure")
	End With
	With pjOneCompany
		.Reset()
		.AddOneArrayEle("ProductList", pjArray.MainJSonStr, True)
		.AddEle("CompanyName", "Microsoft")
		.AddSymbol(PigJSon.xpSymbolType.EleEndFlag)
	End With
	.AddArrayEleValue(pjOneCompany.MainJSonStr, True)
	With pjArray
		.Reset()
		.AddEle("", "Chrome", True)
		.AddEle("", "YouTube")
		.AddEle("", "Android")
	End With
	With pjOneCompany
		.Reset()
		.AddEle("CompanyName", "Google", True)
		.AddOneArrayEle("ProductList", pjArray.MainJSonStr)
		.AddSymbol(PigJSon.xpSymbolType.EleEndFlag)
	End With
	.AddArrayEleValue(pjOneCompany.MainJSonStr)
	.AddSymbol(PigJSon.xpSymbolType.ArrayEndFlag)
	.AddEle("TotalCompanies", 2)
	.AddSymbol(PigJSon.xpSymbolType.EleEndFlag)
	If .ParseJSON() = "OK" Then
		Debug.Print(.MainJSonStr)
		Debug.Print(.GetStrValue("Name"))
		Debug.Print(.GetIntValue("TotalCompanies").ToString)
		Debug.Print(.GetStrValue("CompanyProductList[0].CompanyName"))
		Debug.Print(.GetStrValue("CompanyProductList[0].ProductList[2]"))
		Debug.Print(.GetStrValue("CompanyProductList[0].ProductList[3]"))
		Debug.Print(.GetStrValue("CompanyProductList[1].CompanyName"))
		Debug.Print(.GetStrValue("CompanyProductList[1].ProductList[1]"))
		Debug.Print(.GetStrValue("CompanyProductList[1].ProductList[2]"))
	End If
End With

Return results

{"Name":"Company products","CompanyProductList":[{"ProductList":["Windows","SQL Server","Office","Azure"],"CompanyName":"Microsoft"},{"CompanyName":"Google","ProductList":["Chrome","YouTube","Android"]}],"TotalCompanies":"2"}
Company products
2
Microsoft
Office
Azure
Google
YouTube
Android
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 netcoreapp3.1 is compatible. 
.NET Framework net20 is compatible.  net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  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 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 2.0

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • net5.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.5.16 175 5/28/2023
1.5.10 444 6/15/2022
1.5.5 604 10/10/2021
1.3.5.6 534 7/30/2021
1.3.3.16 540 7/19/2021
1.3.3.12 620 7/10/2021
1.3.2 648 3/28/2021
1.3.1 611 3/10/2021
1.2.0 588 2/2/2021
1.1.0 597 1/28/2021
1.0.0 587 1/23/2021

Increase support for .net 5.0 and .net core 3.1