Sourcing json arrays using list widget

I have json content as an array of objects in my gatsby site in the format

[{text: 'lorem', image:'some Image'}, {text: 'lorem', image:'some Image'}, 

… ]

I tried this option, using the list widget in config.yml

- label: "Products Section"
    name: "Products"
    file: "src/content/productData.json"
    fields:
      - label: "Products"
        name: "productList"
        widget: "list"
        fields:
          - {label: "Caption", name: "text", widget: string,}
          - {label: Image, name: image, widget: image}

I receive an empty list with the above option.
Are there any changes that can be made to get it to work? (in either the config or the JSON file structure)

I found part of the answer here:

This appears to be a repeat of

So basically netlifycms does not support editing arrays at root level

The issue is open here

But I would still like to know how I can change the json file structure to be able to use the list widget properly

You should name the list like:

"productList": [{text: 'lorem', image:'some Image'}, {text: 'lorem', image:'some Image'}
1 Like

That was fast, I implemented this and it works like a breeze.
Thanks @tomrutgers :+1:
This is why I like netlify :ok_hand:

2 Likes