How to parse an Array field in front-end?

Hi,
I got a field like -
“images”: [
“22_85_evathe1.jpg”,
“22_86_evathe2.jpg”,
“22_89_evathe5.jpg”,
“22_1246_648x2441.jpg”
],
How do i access the first element in the front-end? Please help. Thanks in advance.

Hi,

I’m guessing you’re speaking on Javascript @subhendu.gogoi ? If yes, here is a fiddle :

https://jsfiddle.net/tmsg0fg8/5/

Please note that your “images” need to be between {bracket} to be readable.

Or I did not understand what your question was ?

Thanks for replying… But, I am explaining My issue in brief.

I have a json response in Algolia as -
{
“businessId”: 18,
“businessName”: “Spa Evanthe”,
“images”: [
“22_85_evathe1.jpg”,
“22_86_evathe2.jpg”,
“22_87_evathe3.jpg”,
“22_88_evathe4.jpg”,
“22_89_evathe5.jpg”,
“22_1246_648x2441.jpg”
],
“minimumAmount”: 0
}

Now, I want to use the first element of “images” field. How do i use it using instantsearch.js in front-end.
Note: {{{_highlightResult.images[0].value}}} does’not work. Please Help!!!

Ok, I was not sure of your request.

Other stupid questions but :

  • Are you sure “images” is in _highlightResult ?
  • I don’t think you need to specify “.value” as images in an array and not an object.

In mustache.js, if you want a specific index, it’s “.Index” instead of “[index]”

So in my opinion, it should work with {{{_highlightResult.images.0}}}

Thanks.

But I had to put “.value” in the end to get the value. eg. - {{{_highlightResult.images.0.value}}}
This solved My issue.