JSON input type?

Is there a way to allow content editors to upload JSON files and then be able to query the JSON data?

I guess you could use a plain text field and allow pasting the JSON directly in there and then parse it in the page templates, but this seems very prone to error so I don’t want to do this.

Another option would be to use a file upload input, but again prone to error as there is no validation available to restrict which file types you can upload (i.e. only .json files). This also only return a URL to the hosted JSON file, and not the file contents, so would then have to make a run-time request to fetch the data, so also don’t want to go down this route.

Am I missing something? Is there a good way to do this?

This particular use case is for Lottie animations which are exported as JSON files and I’d like to allow content editors to be able to change this as they please, just like any other image.

Huh, Lottie’s cool.

Anyway, the only way to do it at the moment is with plain text like you said, unless you have lots of them and want to go down the custom API route.

Hey Sean, @marcellothearcane is right. Adding the JSON to a custom field it’s the way to do this. Follow this article to learn how to do it:

1 Like

Thanks for that - might try the custom field, though by the sounds of it it’s pretty much the same as the text input approach I mentioned (perhaps with slightly nicer formatting in the CMS) so not sure it’s going to work

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.