I have these JSON Object , I read it well , But when i read oauth value i got an empty result ,
How I can read it ?
{
"status": true,
"message": "Success",
"items": {
"id": 6,
"name": "Tesst1",
"email": "[email protected]",
"image": "https://www.website.com/images/man.png",
"created_at": "2017-08-24 09:18:15",
"updated_at": "2017-08-24 09:18:15",
"oauth": {
"token_type": "abc",
"expires_in": 1296000,
"access_token": "jI5NiwiZXhGVzIjpbXX0.RaC3ixxUeyYnCB6vNlwKsdjf09UeOwUJlcKmKErmE_LTAeQ-4fm8iBOKqUgpikTkyB3ztDGf4DAsaeEjUMqH76jZdbPHnX0vr676dCXkEunWoDEB8sYiHz7XRVgQ5W0O9yybA93mPO_XyrWPibkGW7GLQOApRD605N0e6vw0v9Kb_WQBim7zjTNqoLM1fSjgKJezFqf9_s3KIqBc4bjsayYLl7duzo2fzRmWtnGFfbsgO6YcaIz8ezNtWbtixLRMKnJEj1-MluqjWubsbq_gTI6yiyyac3_oY22Ge0QDdCtljadgO7wRz5VT5aJkxmJRB90u0ovm0tpGzYOO_4giY-J5egpOptjt2VZbPeM-vWPEo4-c6NYMZx6WqxBHjkZwiKUsM-tufzl5P5lFRJ9V_rBUBHEiSonTAk9FVDAwjqLc6N_IC1lsFDEC_3NBy4",
"refresh_token": "def502003e7826477c1072497ad66d7f11ea29e81a0fafef6223a63b6a0a3d18de71165afb9a340d10facca3ac7ee955aac5786a5c66a39cdf77e3f6449458e07271cbcde699aabf4d7f72dad10d586c37497216552f88460e50e9ea4944214984d5b23bac04b5f8265d132"
}
}
}
If i read the oauth as a JSON Object I got an exception about unsupported conversion,
conversion from TJSONObject to string is not supported
what is the wrong with my code ??
if JsonRespnse <> '' then
begin
jsonObiekt := TJSONObject.ParseJSONValue
(TEncoding.ASCII.GetBytes(JsonRespnse), 0) as TJSONObject;
try
try
LoginValue := jsonObiekt.get('status').JsonValue;
LoginValueIsTrue := StrToBool(LoginValue.value);
if LoginValueIsTrue = True then
begin
ItemsValue := jsonObiekt.get('items').JsonValue;
if ItemsValue is TJSONObject then
begin
strIdValue := ItemsValue.GetValue<string>('id');
// strOuthValue := ItemsValue.GetValue<string>('oauth');
OauthValue := TJSONObject(ItemsValue).get('oauth').JsonValue;
if OauthValue is TJSONObject then
Memo1.Lines.Add('oauth : ' + OauthValue.value);
end;
end;
except
on E: Exception do
ShowMessage('Read JSON : ' + E.Message);
end;
finally
jsonObiekt.Free;
end;
end;