JSON Superobject (1)

Source: Internet
Author: User

have been looking forward to Delphi can directly support the "regular expression" and "JSON";

When Delphi 2009 came in, there was JSON, but it was not good, so I tried a little bit. This is the previous link: what is JSON?

Delphi 2010 with two related units: Dbxjson, Dbxjsonreflect seems very powerful, but mainly to datasnap preparation; Try a half-day, also very disappointed: may give Datasnap network data pass enough, but too shabby, seems to have not finished, to Chinese support also have problems.

I want to wait, find a third party, really found a surprise: Json–superobject v1.1 (Introduction, download), Henri gourvest masterpiece!

There is also an XML-related unit, take a slow look.


Let's start with a simple test:

UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;typeTForm1 =class(Tform)    Button1:tbutton; Button2:tbutton;procedureButton1Click (Sender:tobject);procedureButton2click (Sender:tobject);End;varForm1:tform1;Implementation{$R *.DFM}usesSuperobject;//superobject advocates the use of interfaces; ParseString is the class method for Tsuperobject classesprocedureTform1.button1click (Sender:tobject);varJo:isuperobject;beginJO: = tsuperobject.parsestring (' {' No1 ': ' Zhang San ', ' No2 ': ' John Doe '} '); ShowMessage (jo[' No1 ']. asstring);{Zhang San}End;//have a common function so, can be easily implemented interfaceprocedureTform1.button2click (Sender:tobject);varJo:isuperobject;beginJO: = SO (' {' No1 ': ' Zhang San ', ' No2 ': ' John Doe '} '); ShowMessage (jo[' No2 ']. asstring);//John DoeEnd;End.


Why use interface-based?

I guess: A JSON object may contain too many sub-objects, it is easier to release the interface, because it is automatically released;

In addition, the function of the new iountils unit of Delphi 2010 is given by means of structure, and the structure is self-releasing;

Automatic release! Is this going to be a direction? But it does write a lot less code.

JSON Superobject (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.