Показать сообщение отдельно
  #4  
Старый 29.12.2020, 09:10
lmikle lmikle вне форума
Модератор
 
Регистрация: 17.04.2008
Сообщения: 8,015
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
По умолчанию

Ты спотыкаешься, потому что у тебя в salePrices массив, а не одиночный объект. Вот так все работает:
Код:
uses
  System.JSON;

procedure TForm1.Button1Click(Sender: TObject);
var
 I : Integer;
 str : String;
 json : TJSONObject;
 _rows : TJSONArray;

 S : String;
begin
  str := Memo1.Lines.Text;
  json := TJSONObject.ParseJSONValue(str) as TJSONObject;
  _rows := json.GetValue('rows') As TJSONArray;
  For I := 0 To _rows.Count-1 Do
    Begin
      S := 'name = ' + (_rows.Items[i] As TJSonObject).Values['name'].Value + #13#10;
      S := S + 'salePrices[0].value = ' +
        (((_rows.Items[i] As TJSonObject).Values['salePrices'] As TJSonArray).Items[0] As TJSonObject).Values['value'].Value
        + #13#10;
      S := S + 'images.mets.href = ' +
        (((_rows.Items[i] As TJSonObject).Values['images'] As TJSonObject).Values['meta'] As TJSonObject).Values['href'].Value;
      ShowMessage(S);
    End;
  json.Free;
end;

PS. Не красиво, зато понятно откуда куда ноги растут.
Ответить с цитированием