Как распарсить json

joker777

Ефрейтор
Сообщения
9
Реакции
0
Приветствую, подскажите, как распарсить такой json. Нужно получить значения "name", "value" в "salePrices" которое и значение "href" в "images".
У меня получается только "name" забрать, а во вложенных не получается.

Код:
{
  "context" : {
    "employee" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "employee",
        "mediaType" : "application/json"
      }
    }
  },
  "meta" : {
    "href" : "https://hi.ru",
    "type" : "product",
    "mediaType" : "application/json",
    "size" : 3,
    "limit" : 1000,
    "offset" : 0
  },
  "rows" : [ {
    "meta" : {
      "href" : "https://hi.ru",
      "metadataHref" : "https://hi.ru",
      "type" : "product",
      "mediaType" : "application/json",
      "uuidHref" : "https://hi.ru"
    },
    "id" : "35029f1a-458f-11eb-0a80-01180027c2f9",
    "accountId" : "b21a33bb-458e-11eb-0a80-06920000f8d9",
    "owner" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "employee",
        "mediaType" : "application/json",
        "uuidHref" : "https://hi.ru"
      }
    },
    "shared" : true,
    "group" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "group",
        "mediaType" : "application/json"
      }
    },
    "updated" : "2020-12-24 05:35:34.711",
    "name" : "Первый",
    "code" : "00001",
    "externalCode" : "3PIdNwbEgh8qIj0Wcu8OR1",
    "archived" : false,
    "pathName" : "Атата",
    "productFolder" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "productfolder",
        "mediaType" : "application/json",
        "uuidHref" : "https://hi.ru"
      }
    },
    "uom" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "uom",
        "mediaType" : "application/json"
      }
    },
    "images" : {
      "meta" : {
        "href" : "https://hi.ru",
        "type" : "image",
        "mediaType" : "application/json",
        "size" : 1,
        "limit" : 1000,
        "offset" : 0
      }
    },
    "minPrice" : {
      "value" : 0.0,
      "currency" : {
        "meta" : {
          "href" : "https://hi.ru",
          "metadataHref" : "https://hi.ru",
          "type" : "currency",
          "mediaType" : "application/json",
          "uuidHref" : "https://hi.ru"
        }
      }
    },
    "salePrices" : [ {
      "value" : 10000.0,
      "currency" : {
        "meta" : {
          "href" : "https://hi.ru",
          "metadataHref" : "https://hi.ru",
          "type" : "currency",
          "mediaType" : "application/json",
          "uuidHref" : "https://hi.ru"
        }
      },
      "priceType" : {
        "meta" : {
          "href" : "https://hi.ru",
          "type" : "pricetype",
          "mediaType" : "application/json"
        },
        "id" : "b2426bbb-458e-11eb-0a80-03e50028118f",
        "name" : "Цена продажи",
        "externalCode" : "cbcf493b-55bc-11d9-848a-00112f43529a"
      }
    } ],
    "buyPrice" : {
      "value" : 0.0,
      "currency" : {
        "meta" : {
          "href" : "https://hi.ru",
          "metadataHref" : "https://hi.ru",
          "type" : "currency",
          "mediaType" : "application/json",
          "uuidHref" : "https://hi.ru"
        }
      }
    },
    "barcodes" : [ {
      "ean13" : "2000000000015"
    } ],
    "paymentItemType" : "GOOD",
    "discountProhibited" : false,
    "weight" : 0.0,
    "volume" : 0.0,
    "variantsCount" : 0,
    "isSerialTrackable" : false,
    "trackingType" : "NOT_TRACKED",
    "files" : {
      "meta" : {
        "href" : "https://hi.ru",
        "type" : "files",
        "mediaType" : "application/json",
        "size" : 0,
        "limit" : 1000,
        "offset" : 0
      }
    }
  }, {
    "meta" : {
      "href" : "https://hi.ru",
      "metadataHref" : "https://hi.ru",
      "type" : "product",
      "mediaType" : "application/json",
      "uuidHref" : "https://hi.ru"
    },
    "id" : "3e1d2332-458f-11eb-0a80-005e0027014e",
    "accountId" : "b21a33bb-458e-11eb-0a80-06920000f8d9",
    "owner" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "employee",
        "mediaType" : "application/json",
        "uuidHref" : "https://hi.ru"
      }
    },
    "shared" : true,
    "group" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "group",
        "mediaType" : "application/json"
      }
    },
    "updated" : "2020-12-24 05:36:10.365",
    "name" : "Отактоn",
    "code" : "00002",
    "externalCode" : "gnl2GJQriCxBjYGLX7DID2",
    "archived" : false,
    "pathName" : "Упс",
    "productFolder" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "productfolder",
        "mediaType" : "application/json",
        "uuidHref" : "https://hi.ru"
      }
    },
    "uom" : {
      "meta" : {
        "href" : "https://hi.ru",
        "metadataHref" : "https://hi.ru",
        "type" : "uom",
        "mediaType" : "application/json"
      }
    },
    "images" : {
      "meta" : {
        "href" : "https://hi.ru/Вот-так-так/images",
        "type" : "image",
        "mediaType" : "application/json",
        "size" : 1,
        "limit" : 1000,
        "offset" : 0
      }
    },
    "minPrice" : {
      "value" : 0.0,
      "currency" : {
        "meta" : {
          "href" : "https://hi.ru",
          "metadataHref" : "https://hi.ru",
          "type" : "currency",
          "mediaType" : "application/json",
          "uuidHref" : "https://hi.ru"
        }
      }
    },
 

Шпак

Ефрейтор
Сообщения
8
Реакции
0
1
2
3
4
5
6
7
8
9
10
var JSON: TJSONObject;
begin
JSON:=TJSONObject.ParseJSONValue(cJsonStr,False, True) as TJSONObject;
try
ShowMessage(JSON.Values['firstName'].Value);
ShowMessage(JSON.Values['lastName'].Value);
finally
JSON.Free;
end;
end;

Не благодарите
 

joker777

Ефрейтор
Сообщения
9
Реакции
0
1
2
3
4
5
6
7
8
9
10
var JSON: TJSONObject;
begin
JSON:=TJSONObject.ParseJSONValue(cJsonStr,False, True) as TJSONObject;
try
ShowMessage(JSON.Values['firstName'].Value);
ShowMessage(JSON.Values['lastName'].Value);
finally
JSON.Free;
end;
end;

Не благодарите
Попробую, но думаю не получится всеравно даже так