Parsing json array using uLkjson

Back into delphi7…

Needing to transfer some data over the net from a server to my delphi application, it seemed like a good idea to use JSON and according to there are no less than three libraries for parsing json in delphi. The first one webstart / Delphi web utils looked pretty good, but all documentation and examples was in Spanish… Well, learning Spanish is no bad plan, but not today.

The next one, JSON Delphi Library, uLkJSON seemed a bit more simple. No documentation but a few examples – of which none covered arrays which I needed to use…

At last, JSON superobject seemed to have everything, but didn’t compile under delphi 7.

Well, then, use the source, Luke,

Digging through the source of uLkJSON, i managed at least to dig information out of the arrays I had put up. Having a form with a Memo named Memo1, this lists the names and values of the arrays into the Memo:

procedure listarray(returnval: string);
  systems : TStrings;
  returnval: string;
  i,j: integer;
  list: TlkJSONObject;
  json:= TlkJSON.ParseText(returnval);
  for i:=0 to pred(json.Count) do begin
// This is the named array, name in name, the array in Objvalue
{   list is the array it self. This may be too much jiggling back and forth between object types, but at least it works...}
    for j := 0 to pred(TlkJSONobject(list).count) do

Not too hard, — if it just had been some documentation or an example on this, that would have saved me a day. Hopefully this saves a day for someone else.

This entry was posted in Data. Bookmark the permalink.

3 Responses to Parsing json array using uLkjson

  1. hgourvest says:

    I just uploaded a new release that work with Delphi 6,
    I guess it will work with delphi 7.
    get the source Luke 😉


  2. Morten says:

    Great! Thanks, I’ll have a look at it.

  3. d0ynex7 says:

    You really are dilligent. The source contain more than 2000 lines of code. Hat’s off.

Comments are closed.