P
P
Peter2017-10-16 18:26:17
C++ / C#
Peter, 2017-10-16 18:26:17

How to select the desired value from the json response?

Good afternoon, how can I choose from the json response of VkApi the links to the photos I need.
I get this response:

{
"response":{
"count":4,
"items":[
{
"id":311889034,
"album_id":-6,
"owner_id":224327324,
"photo_75":"https://pp.userapi.com/c9503/v9503324/3d3b/8zNzFPaxxMw.jpg",
"photo_130":"https://pp.userapi.com/c9503/v9503324/3d3c/h9LxM-BqRao.jpg",
"photo_604":"https://pp.userapi.com/c9503/v9503324/3d3d/uam3AU-Jcy0.jpg",
"photo_807":"https://pp.userapi.com/c9503/v9503324/3d3e/eao9kRH8Q_4.jpg",
"width":800,
"height":600,
"text":"",
"date":1379451527,
"post_id":1
},
{
"id":312064459,
"album_id":-6,
"owner_id":224327324,
"photo_75":"https://pp.userapi.com/c304307/v304307324/626b/YgvoSAHcHQ8.jpg",
"photo_130":"https://pp.userapi.com/c304307/v304307324/626c/UcjIu-7nJKI.jpg",
"photo_604":"https://pp.userapi.com/c304307/v304307324/626d/uEPA7uLT5GA.jpg",
"width":600,
"height":600,
"text":"",
"date":1379694645,
"post_id":2
},
{
"id":331429690,
"album_id":-6,
"owner_id":224327324,
"photo_75":"https://pp.userapi.com/c617231/v617231335/9fc2/co1UOKpF7GE.jpg",
"photo_130":"https://pp.userapi.com/c617231/v617231335/9fc3/_3weMYE5ulk.jpg",
"photo_604":"https://pp.userapi.com/c617231/v617231335/9fc4/f-ojcC_UcHw.jpg",
"width":475,
"height":536,
"text":"",
"date":1401006605,
"post_id":11
},
{
"id":329480262,
"album_id":-6,
"owner_id":224327324,
"photo_75":"https://pp.userapi.com/c607729/v607729324/7b6d/lOVlcH4k_6U.jpg",
"photo_130":"https://pp.userapi.com/c607729/v607729324/7b6e/dtLhZVyJ0Tg.jpg",
"photo_604":"https://pp.userapi.com/c607729/v607729324/7b6f/ZReGA82apTc.jpg",
"width":570,
"height":428,
"text":"",
"date":1399029878,
"post_id":7
}
]
}
}

Vk, I understand, I have already begun to partially sign the size of the photo and place a link to it.
How do I choose the largest available version of a photo? Since I see that there are links to "photo_604" and somewhere there is also "photo_807".

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Eremin, 2017-10-16
@Morpheus_God

to work with json - here https://www.newtonsoft.com/json
you need to study section https://www.newtonsoft.com/json/help/html/Querying...

E
EEclipsEE, 2017-10-16
@EEclipsEE

if you don’t want to bother too much and the run is only 807 604, then you can write if so that it would take 807 by default, and if it doesn’t exist, then 604 well. this is provided that there is a choice between 807 and 604 if there are more options, then if conditions will turn out a lot, although who likes what

A
Alex Maximovich, 2017-10-16
@flexer1992

If you need only one photo size, then you can ask the social network only for it, the documentation says about it. Section "parameters" https://vk.com/dev/photos.get

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question