ECasio ECasio - 4 months ago 6x
JSON Question

How can I use the first entry of a JSON data array

I got this JSON as data:

data = {"livemode":false,"pending":

now I want to convert this into a more readable text something like this:

"Pending :" + "\n" + "Amount :" + data.pending[0].amount + "\n" + data.pending[0].currency;

So I want to give back the amount of 0 with the currency of jpy but all I get is an Error or undefined, what I'm doing wrong here?

onRetrieveBalancePressed : function() {
var that = this;
type : "GET",
contentType : "application/json",
url : "https:" + "/retrieve",
processData: true,
dataType : "text",
async: false,

success : function(data, textStatus, jqXHR) {
var sResult = "Balance successfully retrieved! \n"
+"Pending :" + "\n"
+"livemode :" + data.pending[0].amount + "\n"

+"Currency : " + data.pending[0].currency;


First just try to convert your data to JSON using var obj = JSON.parse(data);

then try to get data from obj.

In case of jquery, you can also try this:

var obj = jQuery.parseJSON(data);