Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:19:20+00:00 2026-06-07T23:19:20+00:00

Good evening guys! I’m currently trying to put together a CloudFlare client for the

  • 0

Good evening guys!

I’m currently trying to put together a CloudFlare client for the desktop. I’ve connected to their API and successfully retrieved the JSON results with a POST request (the results of which have been output into a TMemo). I’m now wanting to parse these results into a TListBox (see bolded area for example). The project is being designed in Firemonkey.

Here’s the formatted layout of the response with some example content;

{
 - response: {
   |- ips: [
      |- {
         ip: "xxx.xxx.xxx.xxx",
         classification: "threat",
         hits: xx,
         latitude: null,
         longitude: null,
         zone_name: "domain-example1"
         },
       - {
         ip: "yyy.yyy.yyy.yyy",
         classification: "robot",
         hits: yy,
         latitude: null,
         longitude: null,
         zone_name: "domain-example2"
         }
       ]
   }
  result : "success",
  msg: null
}

I’ve tried several different components – SuperObject, Paweł Głowacki’s JSON Designtime Parser, Tiny-JSON, LKJSON and the built in DBXJSON. However, i’ve no experience with JSON at all and i can’t seem to find the most basic of examples that i can get started from. Many of them show sample data, but all the ones i’ve tried don’t seem to work as i’d expect, most likely because i’m misunderstanding them. I’d assume the components work, so i need guidance on getting started.

There are hundreds, often thousands, of results in the ips “array” (i apologise if that’s not correct, i’d assume it’s known as an array but again, i’m completely new to JSON).

What i’m really looking for is some sort of extremely basic sample code which i can build from (along with what component it uses for parsing and such).

For example, if i wanted to grab every ip from the JSON results, and put each one as a separate item into a TListBox (using TListBox.add method), how would i go about achieving this?

When i say ip, i mean the value (in the formatted layout above, this would be xxx.xxx.xxx.xxx or yyy.yyy.yyy.yyy).

Additionally, if i wanted to find a “record” (?) by it’s IP from the JSON results and output the data to a delphi array – e.g.;

Result : Array of String = ['"xxx.xxx.xxx.xxx"','"threat"','xx','null','null','"domain-example1"'];

is that possible with JSON? (If this is seen as a separate question or too unrelated, please feel free to edit it out rather than close the question as a whole).

The closest i got to this had not only the ip’s, but every other piece of data in a seperate TListItem (i.e. response, ips, ip, classification, xxx.xxx.xxx.xxx and everything else had it’s own item, along with several empty items in between each non-empty item).

I’m sure it’s extremely simple to do, but there’s so much information on JSON that it’s a little overwhelming for people new to the format.

Best Regards,
Scott Pritchard.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:19:22+00:00Added an answer on June 7, 2026 at 11:19 pm

    JSON is very simple and easy to figure out, once you understand the basic concepts. Have a look at http://json.org, where it explains things.

    There are 4 basic concepts in JSON:

    A value is any JSON element: a basic string or number, an array, or an object. (Anything but a pair.)

    An array should be a familiar concept: an ordered list of values. The main difference from Delphi arrays is that JSON arrays don’t have a defined type for the elements; they’re simply “an array of JSON values.”

    A pair is a key-value pair. The key can be a string or a number, and the value can be any JSON value.

    An object is an associative map of JSON pairs. You can think of it conceptually as a TDictionary<string, JSON value>.

    So if I wanted to take a JSON array of data like that, and put it in a TListBox, I’d do something like this (DBXJSON example, warning: not tested):

    procedure TMyForm.LoadListBox(response: TJSONObject);
    var
      i: integer;
      ips: TJSONArray;
      ip: TJSONObject;
      pair: TJSONPair;
    begin
      ListBox.Clear;
      pair := response.Get('ips');
      if pair = nil then
        Exit;
      ips := pair.value as TJSONArray;
      for i := 0 to ips.size - 1 do
      begin
        ip := ips.Get(i) as TJSONObject;
        pair := ip.Get('ip');
        if pair = nil then
          ListBox.AddItem('???', ip.Clone)
        else ListBox.AddItem(pair.JsonString, ip.Clone);
      end;
    end;
    

    Then you have a list of IP addresses, and associated objects containing the full record that you can get at if the user selects one. (If you wanted to put the entire contents of each record into the list control, have a look at TListView. It works better than TListBox for that.)

    And if you want to build an array of strings containing all the values, do something like this:

    function JsonObjToStringArray(obj: TJsonObject): TArray<string>;
    var
      i: integer;
    begin
      SetLength(result, obj.Size);
      for i := 0 to obj.Size - 1 do
        result[i] := obj.Get(i).JsonValue.ToString;
    end;
    

    This is all just sample code, of course, but it should give you something to build on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening guys. I'm currently trying to get started on development of a project
Good evening guys, I'm currently trying to add the visualization functionality of d3 to
Good evening guys! I'm currently designing a desktop interface with various features using Firemonkey/FMX.
Good evening guys, I'm trying to pass multiple checkbox values through AJAX and process
Good evening, here is what I am trying to achieve, I currently have a
Good morning/afternoon/evening guys Here is the thing. I'm making a registering gsp that it
Good evening, In my app that I'm currently developing, I have a class that
Good evening, I have been trying to wrap my head about this, below, code
Good evening, I'm trying to splitting the parts of a german address string into
Good evening guys, how can I run a piece of jQuery/ajax when a certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.