If you're going to do this, at least avoid the insane performance hit of calling into the local filesystem each time.
You could install Ignition Extensions (or search on this forum for access to the IgnitionGateway class, then retrieve the ProjectManager from it).
Once you've got a ProjectManager, you can ask it for a given project by name, which you can then ask for a specific resource by ResourcePath. You then ask the resource for its data under the view.json
key.
This will all work off the in-memory representation of the project and should be dramatically faster than reading from the filesystem each time.
There's possibly also a better way to do this without the raw project resource involved at all, but it's also possible such a thing isn't actually exposed to you in scripting.