08.05.2024, 21:44
|
|
Местный
|
|
Регистрация: 13.07.2006
Адрес: на земле
Сообщения: 562
Версия Delphi: Delphi 11
Репутация: 18
|
|
Код:
var
JSONObj: ISuperObject;
CostValue: string;
begin
JSONObj := SO('{"num": "1", "object": "car", "active": 1, "state": 0, "desc": [{"model": "audi", "price": {"currency": "EUR", "cost": "8000"}, "color": "red", "equipment": "full"}], "owner": {"name": "Ivanov", "adress": "First street", "house": "45/1"}, "extra": "none"}');
// Проверяем, существует ли поле "desc" в JSON
if JSONObj['desc'] <> nil then
begin
// Получаем массив объектов desc
if JSONObj['desc'].AsArray.Length > 0 then
begin
// Получаем первый объект в массиве desc
CostValue := JSONObj['desc'][0].S['price.cost'];
// Теперь в CostValue содержится значение "cost"
ShowMessage('Cost: ' + CostValue);
end;
end;
end;
__________________
Нет ничего не возможного. Вопрос только во времени...
|