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

  • Home
  • SEARCH
  • 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 6071507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:03:18+00:00 2026-05-23T10:03:18+00:00

I am really new to Delphi and I am doing an experiment on how

  • 0

I am really new to Delphi and I am doing an experiment on how to output JSON array through delphi. This maybe sound simple to anyone but I just dont know how. I already created a simple program.

Now, what i want to do is to create a command/request with parameter like:

http://localhost:8001/hello?json={"names":["Jay","Chris","John"]}

that would create a result in the browser like this:

{
result: ["Hello Jay","Hello Chris","Hello John"],
id: "",
time_elapsed: 0
}

Please, i really need help on this. Anybody?

EDIT:
This is the code i just did today but it still doesn’t show my desired output:

procedure TPrimeJSONMHelloPeople.ProcessJSONRPCRequest(
  var ResultValue: TlkJSONbase; var ResultSuccess: Boolean);
  var

    jsonPeople:TlkJSONlist;
    dmPool:TObject;
    dm:TPrimeDataModuleBaseDM;
    i:integer;

  begin
    FjsonObj1 := TlkJSONobject.Create;
    jsonPeople := FjsonObj1.CreateListValue('names');
    jsonPeople.AddVarString('jay');
    jsonPeople.AddVarString('ann');
    jsonPeople.AddVarString('john');
    inherited;

    CheckRequiredParameter('names');

    PrimeDataModuleWebService.TDataModuleDMCreateInstanceDefault(dmPool);
      try
         dm := TPrimeDataModuleDefaultDM(dmPool).GetModule;
         try

         //this part here will loop and output the name
         //if jsonPeople <> nil then

         if Params.Field['names'] <> nil then
           begin
             for i := 0 to FjsonObj1.Field['names'].Count - 1 do
             begin           
               ResultValue := TlkJSONlist.Create
             end;

         end;
       ResultValue := TlkJSONlist.Create;
       finally
       dm.Release;
      end;
    finally
  dmPool.Free;
 end;
   FjsonObj1.Free;
   ResultSuccess := True;
 end;

I don’t know what’s missing in the code, It only shows:
{

result: [ ],
id: "",
time_elapsed: 0

}

and not :
{
result: ["Hello Jay","Hello Chris","Hello John"],
id: "",
time_elapsed: 0
}

  • 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-05-23T10:03:19+00:00Added an answer on May 23, 2026 at 10:03 am

    i have just found the right answer. Here’s the code:

    procedure TSample1.ProcessJSONRPCRequest(
      var ResultValue: TlkJSONbase; var ResultSuccess: Boolean);
      var
    
        dmPool:TObject;
        dm:TPrimeDataModuleBaseDM;
    
        jsonPeople:TlkJSONlist;    //used Tlkjsonlist since I want to create an array
        i:integer;
      begin
      inherited;
        jsonPeople:=TlkJSONlist.Create;  //create jsonPeople as an array
    
        CheckRequiredParameter('names'); //names parameter needed
        PrimeDataModuleWebService.TDataModuleDMCreateInstanceDefault(dmPool);
        try
          dm := TPrimeDataModuleDefaultDM(dmPool).GetModule;
          try
            if Params.Field['names'] <> nil then //check if the names parameter is empty
            begin
              ResultValue:=jsonPeople;
              for i := 0 to Params.Field['names'].Count - 1 do
              begin
                jsonPeople.AddVarString('hello ' + Params.Field['names'].Child[i].value);
              end;
            end;
          finally
            dm.Release;
          end;
        finally
        dmPool.Free;
      end;
      ResultSuccess := True;
    end;
    
    end.
    

    The request is http://localhost/sample1?json={"names":["john","jay"]}
    The output is

    {
    
        -
        result: [
            "hello john"
            "hello jay"
        ]
        id: ""
        time_elapsed: 0
    
    }
    

    Hope this can help someone who is new in creating web service request using delphi.

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

Sidebar

Related Questions

im really new to linq-to-SQL so this may sound like a really dumb question,
this is really strange, i have an array in delphi and fill it with
I'm really new to ASP.Net Mvc, but not new to Asp.Net. I was aware
I'm really new to HTML, but I can't find anywhere how to return the
I'm really new to VSTO so sorry if this is a newbie question. I'm
I am really new to Lazarus/FreePascal and I have no prior Delphi experience. I
Well, I am new to Delphi and really offline programming in general (other than
I really new to Python and coding in general, but I have been making
I am really new to C. I want to use the strpos function but
I`m really new in Objective-C and Mac OSX programming. Can someone give me simple

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.