I have the following json (extract):
[{"series":{"series_long_name":"Micky mouse","id":"17684"},"0":{"listings":"3"}}]
I need to reference the number of listings to populate and autocomplete:
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.append( '<a>' + item.series.series_long_name + '<span class="listings-count">' + item.0.listings + '</span></a>' )
.appendTo( ul );
};
but using item.0.listings throws an error, I guess because I can not add an int as an object key?
I believe that the 0 is being returned as it is a count().
Here is an extract array returned before being encoded:
(int) 0 => array(
'series' => array(
'series_long_name' => 'Micky mouse',
'id' => '17684'
),
(int) 0 => array(
'listings' => '3'
)
),
Any idea how best to tackle this?