Skip to content

Latest commit

 

History

History
125 lines (98 loc) · 2.32 KB

README.md

File metadata and controls

125 lines (98 loc) · 2.32 KB

TulipEasyJsonReader

Tulip Easy Json Reader

Support

  • Windows 32bit and 64bit (Console, VCL, FMX)
  • Android (FMX)
  • MacOS (FMX)

Platform

.

Read Json values exactly as properties.

Before you start you should know:

  • This tool is case sensitive.
  • TulipEasyJsonReader for reading only. you cann't use it to change json values. ( at least for now. maybe later ).
  • TulipEasyJsonReader is a simple tool and it's build to be very simple. not to be full functional.
  • for Spaces in key names use two undersocres

How to use

use the new property jdata of TJsonValue. ( it was before data )

  var
    Jval: TJsonValue;

  ..
   Edit1.Text := jval.jdata.LastName;

example:

{
   "First Name":"Samer",
   "LastName":"Assil",
   "AGE":47,
   "Lang":[
      "Arabic",
      "English",
      "Turkish"
   ],
   "Address":{
      "City":"Ankara",
      "Street":"B123",
      "Tel":[
         { "Home":"123123123" },
         { "Mobile":"123412341234", "Ext":9 }
      ]
   }
}

Case Sensitive

  var
    Jval: TJsonValue;
   ...
  Edit1.Text := jval.jdata.AGE;
  var
    Jval: TJsonValue;
   ...
  // TulipEasyjsonReader is case sensitive.
  Edit1.Text := jval.jdata.LastName;

Space in the key name

to get "First Name" value: // notice there is a space between Frist and Name

  var
    Jval: TJsonValue;
   ...
  // Use two underscores "__" instead of space
  Edit1.Text := jval.jdata.First__Name;

The return is Variant so you can assign it to a variable without warry about casting it. :)

  var
    Jval: TJsonValue;
   ...
  Edit1.Text := jval.jdata.Age; // using age value as string

  var MyAge: Integer;
  MyAge := jval.jdata.Age;  // here using age value as integer :)

Reading from Array

  var
    Jval: TJsonValue;
   ...
   Edit1.Text := jval.jdata.Lang(1); // getting the second element value from the array object.

Object in Array

get Address -> city

  var
    Jval: TJsonValue;
   ...
  Edit1.Text := jval.jdata.Address.City;
  var
    Jval: TJsonValue;
   ...

   Edit1.Text := jval.jdata.Address.Tel(1).Ext; // getting the "ext" value from the second element in "Tel" Array from Address Object :)

Installation

No installation.. Just put TulipEasyJsonReader in uses section. and ready to go.