Importing a JSON file in a server action

Hi,

Is there any way to import a file whose content is formatted as a JSON object? I’m thinking of functionality like the one provided by the step Data Management > Import CSV file except that content of the file would look like this:

{
“param1” : “value1”,
“param2” : “value2”,
“param3” : “value3”
}

Instead of:
param1,param2,param3
value1,value2,value3

Please note: I do not want to do this using the front end. All has to be done from within the server action. The server model I’m using is PHP.

Many thanks,

Alex

Custom extension.
We have one in NodeJS.

I’m guessing you can also use the read file step (if it exists) and then use a Set Value whose expression is the variable containing the file contents, with the formatter to JSON decode it (not sure if that’s in Wappler’s graphical interface)

You can just use a standard API step and point it to the URL of the local file:

You can then also use the Define API Schema button to auto detect its structure for data binding pickers

4 Likes

Thanks everyone!!

It is really easy to use and make standardising elements of a site simple. Use the same lists for countries, currencies, genders, contact titles, statuses etc. across your whole site/app and make changes in just one place to alter them. Great for select/autocomplete/tagify elements that you then want to verify allowed values server-side.

Tip: add the API step in a library action and then use include in each Server Action file where you need to access the list. That way you only need to configure the URL and schema once