V
V
vfvnvsyevsky2014-11-14 19:12:35
JavaScript
vfvnvsyevsky, 2014-11-14 19:12:35

How to read a JSON string?

There is a vk api answer, but I don’t understand how to get information from there, for example, for alert
response: [{
id: 205387401,
first_name: 'Tom',
last_name: 'Cruise',
city: {
id: 5331,
title: 'Los Angeles '
},
photo_50: ' https://pp.vk.me/...0/pV6sZ5wRGxE.jpg ',
verified: 1
}]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cisx, 2014-11-14
@vfvnvsyevsky

to the console console.log(response)
To text:
alert(JSON.stringify(response))
var res = jQuery.parseJSON(response) if the request is json, then this string is not needed
alert(res.photo_50)

O
overmes, 2014-11-14
@overmes

hover and highlight the text with the mouse, open the context menu, click "copy", find the area where you want to paste information, open the context menu and click "paste"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question