-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Is it possible to somehow output the JSON object in an array? I tried doing that manually but the array wrapper is removed upon saving fields.
Currently:
{
"canAdd": true,
"showBreadcrumbs": true,
"showSocialSharing": true
}
However, I'm using Netlify-CMS with Gatsby and I'm trying to Query the JSON using gatsby-transformer-json
but it seems it requires arrays or strings and not an object. If I wrap the Netlify outputted object in an array it works:
[{
"canAdd": true,
"showBreadcrumbs": true,
"showSocialSharing": true
}]
That does the trick but the array wrapper []
is removed on every save. Without the array wrapper, showBreadcrumbs and showSocialSharing are not query-able:
Has anyone tried to import JSON into gatsby before and had better luck? I basically need array instead of key-value.
I ended up querying allFile which allows me to filter on a specific file name such as products.json but it's definitely not ideal. Would prefer just wrapping JSON object in an array for a more simplified graphql query.
query settings {
allFile (filter: {
name: { eq: "products" }
}) {
edges {
node {
childSettings {
canAdd
}
}
}
}
}