Possible to view a json file contents in panel

Hi all,

i have a “data.json” file in the folder “mydata” in my content folder.
I wonder if it’s possible to display the contents of the json file in a structure field in the panel? I think it should work with api in my yaml file but how do i point it to my json file without hardcoding the url?

Is it even possible?

I’m not quite sure what you want to do. Populate a structure field with the contents from the JSON file? Query the json file within a select/multiselect inside a structure?

exactly this :slight_smile:

Still trying to understand what exactly you want to achieve. Could you please describe the workflow you expect?

Okay. I have a form on the frontend. All user inputs are stored in a json file. I just want to have a look at the entries in the json file while browsing the panel without having to ssh/ftp on to the server in order to read it unformatted in an editor.

I see, so on upload you could then populate your structure field with the JSON data.

Basically, all you need to do is read the JSON data into an array, then convert this array to YAML format and do a page update of the field.

So is it one page per upload? Then it’s pretty straightforward, and you don’t need to append to anything.

Not really sure what you mean by upload. The json file is populated with strings users put in on the frontend. All I need is that when i’m in my panel and i check that particular page, the json data at that point in time is populated into a structure field.

where do I implement the logic for this? will I have to generate a yml file out of my json file that then gets importet into my template.yml?

Oh, ok, that was a misunderstanding then.

Nevertheless, IMO it would be easiest to update the page whenever the json file is updated, or store the data in a structure field in the first place, instead of in the JSON file; at least I don’t really see the purpose of it unless you need the json file for other purposes.

Not really sure what would be a good way without actually storing the data in the content (because that’s what the blueprint-generated form reads from).

The easiest alternative would probably be an info field that displays the data via a custom page method.

hehe, that’s it. I want to pass the json file also to an IoT kind of device. If I would store the data in the page.txt of that page, there would be probably too much thinks i woulkd have to filter through on my not so powerful microcontroller.

ok, I’m off to read about that thing…