Expression not evaluated

The expressions marked with #This doesn't work below aren’t being evaluated. It seems to be returned verbatim, as in the screenshot below. I have tried enclosing them in single quotes, double quotes, and plain. How can I fix this?

          - component: oh-repeater
            config:
              sourceType: array
              in: =JSON.parse(items[props.photos].state) # This works fine
              for: photo
              fragment: true
            slots:
              default:
                - component: oh-image
                  config:
                    lazy: true
                    url: =loop.photo.url # This works fine
                    action: photos
                    actionPhotos: 
                      - url: =loop.photo.url # This doesn't work
                        caption: =loop.photo.name # This doesn't work
                    actionPhotoBrowserConfig:
                      type: popup
                      toolbar: false
                      swipeToClose: true
                      exposition: false
                    style:
                      width: 190px
                      height: 106px
                      object-fit: contain
                      padding: 1px

Individual array elements cannot contain expressions. For that particular parameter a JSON serialization is also acceptable so here’s how I made it in one of my widgets:

              actionPhotos: '="[{\"item\": \"" + props.albumArtItem + "\"}]"'

In your case (untested) something like:

              actionPhotos: '="[{\"url\": \"" + loop.photo.url + "\", \"caption\": \"" + loop.photo.name + "\"}]"'

Ugly, but no other choice AFAIK.

Thanks for the suggestion. Out of curiosity, why can’t individual array elements contain expressions?

I got mine to work using:

actionPhotos: =JSON.parse('[{"url":"' + loop.photo.url + '", "caption":"' + loop.photo.name + '"}]') 

it avoids escaping the dbl quotes

so then I found out that this also works:

actionPhotos: ='[{"url":"' + loop.photo.url + '", "caption":"' + loop.photo.name + '"}]'

and your version also works with the single quotes enclosing the whole =xxxx expression.

I am very confused about the single and double quotes. Could you please shed some light about the difference between these three:

something: =items.Itemname.state
vs
something: '=items.Itemname.state'
vs
something: "=items.Itemname.state"

This page seems to offer some clear introduction:
https://docs.octoprint.org/en/master/configuration/yaml.html#scalars

Your version does look nicer indeed, less escaping!

I take it that this is the response to my question “why can’t individual array elements contain expressions?”

As I understand it, and I might be wrong here, is that this yaml:

level1:
  - level2a1: value
    level2a2: value
  - level2b: value

will translate to a json object where the array elements are dictionaries / hashes, not scalars:

{ level1: [ {level2a1: value, level2a2: value}, {level2b: value} ] }

hence my confusion why expressions can’t be evaluated there. Could you point me in the general location in the source code where the expression evaluation / extrapolation is being done?

Ah, no it was actually in response to:

I’m not sure exactly (or I don’t remember) if there’s a good not to allow expressions in array members, all I can say is, it isn’t implemented.