Answer the question
In order to leave comments, you need to log in
[CBuilder XE6] Get value from JSON?
Good day! I've asked this question on several forums and haven't received an answer yet. I googled, but even here I failed: D Anything: buy XE / first experiments / delphi, the latter, by the way, everywhere and everywhere). I myself tried through dynamic_cast and not only, but I got only errors (yes, yes, I did delete with Free). I understand that the format is lightweight and easy to parse, but for now I would like to see a working example, then based on it I will already begin to deal with the standard TJSONObject class and add / change the functionality of my utility.
Sobsno subject: from the response from the API VK I need title, id, owner_id, player
{
"response": {
"count": 1638,
"items": [
{
"id": 168886508,
"owner_id": -51189706,
"title": "Jenga Cat",
"duration": 83,
"description": "Еще больше крутых видео: vk.com\/just_vid\nРекомендую!",
"date": 1401295313,
"views": 754,
"comments": 5,
"photo_130": "http:\/\/cs541206.vk.me\/u2949887\/video\/s_af146ce5.jpg",
"photo_320": "http:\/\/cs541206.vk.me\/u2949887\/video\/l_1b666cdd.jpg",
"player": "http:\/\/vk.com\/video_ext.php?oid=-51189706&id=168886508&hash=a89ac9f2208445bf",
"can_comment": 1,
"can_repost": 1,
"likes": {
"user_likes": 0,
"count": 35
},
"repeat": 0
}
]
}
}
Answer the question
In order to leave comments, you need to log in
Twenty-five again) If for me it was a matter of 5 minutes, then I would not ask for help)
This concerns the code, and not the objects themselves, values and arrays ...
I found these articles because they are usually in the forefront.
UPD: Found an example:
#include <Data.DBXJSON.hpp>
#include <memory>
...
std::auto_ptr<TJSONObject> object(static_cast<TJSONObject*>(TJSONObject::ParseJSONValue(Memo1->Lines->Text)));
TJSONObject* response = static_cast<TJSONObject*>(object->Get("response")->JsonValue);
TJSONArray* items = static_cast<TJSONArray*>(response->Get("items")->JsonValue);
TJSONObject* id = static_cast<TJSONObject*>(items->Get(0));
ShowMessage(id->GetValue("id")->ToString());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question