環境:
uses IdHTTP, Data.DBXJSON;
...
...
procedure TForm1.Button1Click(Sender: TObject);
var
H: TIdHTTP;
JSON: String;
JO: TJSONObject;
JV: TJSONValue;
JP: TJSONPair;
begin
H:=TIdHTTP.Create(nil);
H.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)';
JSON:=H.Get('http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_3673.tw');
JO := TJSONObject.ParseJSONValue(JSON) as TJSONObject;
JP := JO.Get(0);
ShowMessage(JP.ToString);
ShowMessage(JP.JsonString.Value);
JV:=(JP.JsonValue as TJSONArray).Get(0);
ShowMessage((JV as TJSONObject).Get('n').JsonValue.Value);
FreeAndNil(JO);
FreeAndNil(H);
end;