Read and write to the view.json

Hello everyone,

i need your help with the following task. I would like to read the “view.json” files from the gateway’s project directory. More specifically, I would like to read the parameters and permissions from existing views in a project and write them to an XML file. I have already come across the "ViewConfig" of the com.inductive.perspective.common.config. However, I despair about the command “fromProjectResource(ProjectResource resource, com.inductiveautomation.ignition.common.gson.Gson gson)”. How do I have to initialize and pass the Gson or how do I use this command?

Following is my previous code:


I use this Code in the Gateway scope.

Thanks for your help!

i dont know if its any usefull, but i accessed views (aswell as one that accesses this for vision (older version though)) through this. though it didnt really have anything to do with permissions so i have no idea if you can find anything usefull here.

1 Like

Thank you for the answer. In fact, I'm currently accessing the parameters in the ".json" via a path. However, there is certainly a more elegant solution for this using the object "ViewConfig" and the "getParamDefinitions" method. However, as I said, I don't know how to initialize the "Gson" object and pass it to the "fromProjectResource" method. I've already tried "PerspectiveModule.createPerspectiveCompatibleGson()", unfortunately without success.