Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiRAD StudioTech Partner

Super Fast JSON Processing In Delphi With Winsoft.sk JSON Library

JSON is a text-based data format following JavaScript object syntax, which was popularized by Douglas Crockford. Even though it closely resembles JavaScript object literal syntax, it can be used independently from JavaScript, and many programming environments feature the ability to read (parse) and generate JSON. JSON exists as a string, and is useful when you want to transmit data across a network no matter System, Architecture or Programming Language.

One of the more powerful Libraries for handling JSON strings with Delphi is Winsoft JSON Library. Is very simple to use but very versatile to work with.

Menu Tools->Options->Language->Delphi->Library

Installation

Download the latest version here, and unzip the downloaded file to your default components folder.

This is a non-visual library, so you don’t need to install it on IDE.

Add a folder according to your Delphi version and Platform in Tools->Options->Language->Delphi->Library to Library Path

Sample

Generic JSON files viewer

Reading and parsing JSON Files

In the following example we are going to implement a generic JSON viewer that shows structure of the selected JSON file.

You can open this sample project at <Winsoft JSON Install Folder>\Examples\Delphi\VCL\Demo.dpr

The following code takes some steps to start parsing of a JSON file

  1. Load a JSON file you select from Open dialog
  2. Create instance of TJson object
  3. Load content from selected file to Tjson object via ParseUtg8File(OpenDialog.FileName)
  4. Call recursive function Show(nil, '' jsonItem) for root node

This function starts checking node data type via some predefined item classes like TJsonNull, TJsonTrue, TJsonFalse, TJsonString and adding to Treeview. If the item being checked is an array, the TJsonArray function is called recursively with new parameters in order to add array elements as child of current item. Checking for TJsonObject add object properties to with current object as parent

Like what you see? You can get JSON and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4 today!


What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

20+ years of experience on Software Development, using Delphi since version 1
Related posts
C++Delphi

Artificial Intelligence: Expectations vs. Reality

CodeDelphiIDERAD Studio

Delphi 11 Alexandria Defines

DelphiDeveloper InterviewsInterviewNews

What Is It Like To Be A Developer David Cornelius?

C++DelphiDeveloper InterviewsInterviewNews

What Is It Like To Be A Developer Stephane Jordi?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES