Extract values ​​from the JSON file using SuperObject


As the title suggest I am trying to extract a value from a very simply structured JSON file using Delphi 7 and the SuperObject Library, but I have yet to find any examples that cover this most basic topic and was hoping some of the gurus here might be able to offer me some assistance.

What I have is a simple JSON file (named test.json) that has the following structure and what I am wanting to know is how can I load this file in delphi and then extract the value for "last name" from the information provided.

I am sure this is an extremely simple task, but as I stated before I was not able to find any examples on how to do this and was hoping for some help.

example JSON file

  id: 212,
  first_name: "bob",
  last_name: "smith",
  age: 25

First, declare an instance of the object, as an ISuperObject interface in this case. Then, assign it using TSuperObject.ParseString or even just SO to parse your JSON string. Then, you can read the values using the one-letter properties, depending on the type of value you're reading...

  O: ISuperObject;
  ID, Age: Integer;
  FirstName, LastName: String;
  O:= SO(MyJsonString);
  ID:= O.I['id'];
  FirstName:= O.S['first_name'];
  LastName:= O.S['last_name'];
  Age:= O.I['age'];

Please bear in mind however that things don't typically work this way here at Stack Overflow. The only reason I answered is because it was quick and easy, and because you appear to be new here. There are plenty of resources out there on how to use SuperObject; in the demos that you downloaded with the library, all over Google, and right here in Stack Overflow.