我有以下JSON結構:訪問內JSON值
concurrence: [
{
id: "481-13",
price: "11.5",
concurrent: {
id: 13,
name: "NAME1",
price: "11.5"
}
},
{
id: "481-14",
price: "12.25",
concurrent: {
id: 14,
name: "NAME2",
price: "12.25"
}
}
]
我怎樣才能獲得concurrent.id
價值?我嘗試使用RADStudio文檔中列出的FindValue()
方法,但它不存在(至少在10.1柏林中)。
我訪問同意數組是這樣的:
concurrents := product.Get('concurrence').JSONValue as TJSONArray;
for j := 0 to concurrents.Size-1 do
begin
concurrent := concurrents.Get(j) as TJSONObject;
json_s := concurrent.Get('id').JsonValue as TJSONString;
my_id := json_s.Value;
json_s := concurrent.Get('price').JsonValue as TJSONString;
my_price := json_s.Value;
json_s := concurrent.FindValue('concurrent.id') as TJSONString;//NOT WORKING
my_concurrent_id := json_s.Value;
end;
是否有另一種方式來訪問內部concurrent
值?
是它不只是json_s:= concurrent.Get(「身份證」)作爲TJSONString – Dsm
,會給你的第一個「ID 「字段,而不是下面的」併發「字段。它部署的JSON很差,但我必須處理它。 –
遍歷數組,直到找到想要的項目,然後讀取該對象。 –