@booomheadshot

Как правильно парсить JSON ответы ВКонтакте?

Не могу понять логику работы родного DBXJSON. Первые две страницы гугла по запросу: "Delphi Json" были перелопачены. Я очень устал. Дайте, пожалуйста, готовое решение по парсингу JSON. Конкретно интересует ответ ВК по запросу на wall.get.
Ответ имеет следующий вид:
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
}
}]
}
  • Вопрос задан
  • 3116 просмотров
Пригласить эксперта
Ответы на вопрос 1
Откройте для себя mORMot - synopse.info/fossil/wiki?name=SQLite3+Framework

Будете делать так:

var
v: Variant;

..

v := _JsonFast(ResponseText);

Далее прям по полям:

v.response.reposts.count и т.п.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы