How can I use structured data for dynamically loaded images?

I have a webpage with a lot of images that I load dynamically onto the page dynamically using Javascript/JSON data.

The images’ rendered output is:

<li itemscope itemtype="">  <img src="$  {data.file}" alt="$  {data.alt}" itemprop='contentURL'> <div class="imageInfo">  <h2 itemprop="name">$  {}</h2>  </div>  </li> 

The schema structured data values I get from the JSON file are data.file for the itemprop="contentURL" and for the itemprop="name".

I have read that Google doesn’t use dynamically loaded schema markup unless you use JSON-LD. Currently when I test with Google’s structured data testing tool I see that the test shows there’s no structured data for my dynamically loaded content.

What are the steps I need to take to make sure that Google uses/sees my dynamically loaded structured data?