PigJSonLib 1.3.5.6

Install-Package PigJSonLib -Version 1.3.5.6
dotnet add package PigJSonLib --version 1.3.5.6
<PackageReference Include="PigJSonLib" Version="1.3.5.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PigJSonLib --version 1.3.5.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PigJSonLib, 1.3.5.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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.3.5.6

// Install PigJSonLib as a Cake Tool
#tool nuget:?package=PigJSonLib&version=1.3.5.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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)
	.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("VisitTime", True).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"}
Seow Phong Web Site
http://www.seowphong.com
A website for free software
 and shareware
168
168.88
8/8/2020
2020/9/27 13:33:32
2020/9/27 21: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
  • .NETFramework 2.0

    • No dependencies.
  • .NETFramework 3.0

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PigJSonLib:

Package Downloads
PigJSonDemo

Demo console program for PigJSonLib

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.5.6 55 7/30/2021
1.3.3.16 70 7/19/2021
1.3.3.12 134 7/10/2021
1.3.2 155 3/28/2021
1.3.1 95 3/10/2021
1.2.0 82 2/2/2021
1.1.0 82 1/28/2021
1.0.0 80 1/23/2021

Fix bugs for ParseJSON, add UnlockEndSymbol for insert JSon item.