Answer the question
In order to leave comments, you need to log in
How to parse JSON responses from VKontakte?
I can not understand the logic of native DBXJSON. The first two pages of Google on request: "Delphi Json" were shoveled. I am very tired. Please give a ready solution for parsing JSON. Specifically, I'm interested in the VK response to the request for wall.get.
The response looks like this:
response: {
count: 3651,
items: [{
id: xxxxxx,
from_id: -xxxxxx,
owner_id: -xxxxxx,
date: xxxxxxxxx,
post_type: 'post',
text: 'Текст поста',
signer_id: xxxxxxxx,
is_pinned: 1,
attachments: [{
type: 'photo',
photo: {
id: xxxxxxx,
album_id: -xxxx,
owner_id: -xxxxx,
user_id: xxxxx,
photo_75: 'xxxxx',
photo_130: 'xxxxxx',
text: '',
date: xxxxx,
access_key: 'xxxxxxx'
}
}],
post_source: {
platform: 'android',
type: 'api'
},
comments: {
count: 0,
can_post: 1
},
likes: {
count: 30,
user_likes: 0,
can_like: 1,
can_publish: 1
},
reposts: {
count: 0,
user_reposted: 0
}
}, {
id: 77554,
from_id: -xxxxxx,
owner_id: -xxxxx,
date: xxxxxxx,
post_type: 'post',
text: 'Текст поста',
post_source: {
type: 'mvk'
},
comments: {
count: 0,
can_post: 1
},
likes: {
count: 2,
user_likes: 0,
can_like: 1,
can_publish: 1
},
reposts: {
count: 0,
user_reposted: 0
}
}, {
id: xxxxx,
from_id: -xxxxx,
owner_id: -xxxxx,
date: xxxxxx,
post_type: 'post',
text: 'Текст поста',
attachments: [{
type: 'photo',
photo: {
id: xxxxxx,
album_id: -xxxxx,
owner_id: -xxxxx,
user_id: xxxxxx,
photo_75: 'xxxxx',
photo_130: 'xxxxx',
photo_604: 'xxxxx',
width: 600,
height: 400,
text: '',
date: xxxxx,
post_id: xxxxx,
access_key: 'xxxxx'
}
}],
post_source: {
type: 'mvk'
},
comments: {
count: 0,
can_post: 1
},
likes: {
count: 39,
user_likes: 0,
can_like: 1,
can_publish: 1
},
reposts: {
count: 0,
user_reposted: 0
}
}]
}
Answer the question
In order to leave comments, you need to log in
Discover mORMot - synopse.info/fossil/wiki?name=SQLite3+Framework
You will do this:
var
v: Variant;
..
v := _JsonFast(ResponseText);
Then straight through the fields:
v.response.reposts.count, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question