I have arrived up to here with my code:
JSONArray := TJSONObject.ParseJSONValue(Text) as TJSONArray;
for var JSONValue in JSONArray do
begin
ListBox1.Items.Add(JSONValue.Value);
end;
Please note that Text := '[{"jahre":2},{"jahre":4},{"jahre":15}]'
which is a valid JSON format. How can I get 2019 and 2018 items in the list?
With the above code I get white items in the list box.
Each JSONValue
is a "piece" of your array and each piece is an object. You have to convert the type to TJSONObject
and the you can get the value.
ListBox1.Items.Add((JSONValue as TJSONObject).GetValue('jahre').ToString);
More info can be found in the doc (if you're using 10.3 the JSON library has been improved)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With