Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcel

C# UWP/WinRT Examples


ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
ECC
Email Object
Encryption
FTP
Facebook
Firebase
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
VoiceBase
Walmart
WebSocket
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(C# UWP/WinRT) Loading and Parsing a JSON Array

A JSON array is JSON that begins with "[" and ends with "]". For example, this is a JSON array that contains 3 JSON objects.

[{"name":"jack"},{"name":"john"},{"name":"joe"}]
A JSON object, however, is JSON that begins with "{" and ends with "}". For example, this JSON is an object that contains an array.
{"pets":[{"name":"jack"},{"name":"john"},{"name":"joe"}]}
This example shows how loading a JSON array is different than loading a JSON object.

Chilkat Universal Windows Platform (UWP) / WinRT Downloads

Chilkat for the Universal Windows Platform (UWP)

string strJsonArray = "[{\"name\":\"jack\"},{\"name\":\"john\"},{\"name\":\"joe\"}]";

string strJsonObject = "{\"pets\":[{\"name\":\"jack\"},{\"name\":\"john\"},{\"name\":\"joe\"}]}";

//  A JSON array must be loaded using JsonArray:
Chilkat.JsonArray jsonArray = new Chilkat.JsonArray();
jsonArray.Load(strJsonArray);

//  Examine the values:
int i = 0;
while (i < jsonArray.Size) {
    Chilkat.JsonObject jsonObj = jsonArray.ObjectAt(i);
    Debug.WriteLine(Convert.ToString(i) + ": " + jsonObj.StringOf("name"));

    i = i + 1;
}

//  Output is:

//  	0: jack
//  	1: john
//  	2: joe

//  A JSON object must be loaded using JsonObject
Chilkat.JsonObject jsonObject = new Chilkat.JsonObject();
jsonObject.Load(strJsonObject);

//  Examine the values:
i = 0;
int numPets = jsonObject.SizeOfArray("pets");
while (i < numPets) {
    jsonObject.I = i;
    Debug.WriteLine(Convert.ToString(i) + ": " + jsonObject.StringOf("pets[i].name"));
    i = i + 1;
}

//  Output is:

//  	0: jack
//  	1: john
//  	2: joe

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.