Sorry if I've explained this wrong but I've got an object which is an array and I'm trying to get the fields to output but all I'm getting is [object object]
$.getJSON( "https://service1.homepro.com/smart.asmx/GetFAP_ProfileReviewsJSON?bid=141772&sort=1&page=1", function( data ) {
// console.log(data);
xmlText = data;
var jsonObj = x2js.xml_str2json( xmlText );
// console.log(jsonObj.SMART);
var html = '<div class="review">';
$.each( jsonObj, function( key, answer ) {
// console.log('key', key);
console.log('answer', answer);
html += '<div>' + answer + '</div>';
// html += '<div>' + key + '</div>';
});
$('div').html(html);
});
Can anyone help or show me where I've gone wrong?
Thanks
x2js.xml_str2json()because the return on that function (or method) is probably the issue.console.log('answer', JSON.stringify(answer));and see if that gives you better results[object Object]is the default string representation of objects. Access the properties whose values you want to show instead.