PageReference.forResource
method used in your code gets the reference to the entire static resource (zip folder). In your case, you need to use the overloaded method documented here. Note that the input param path
should include the static resource name as well as shown in the code snippet below. If you don't include the static resource name, you'll get resource not found (404) error.
EmailEditorZipURL
used in your code has query parameters in it and concatenating it with '/Templates/Event_Base_Template.json'
as-is leads to incorrect URL.
You mentioned in your question that the code executes fine anonymously, but I probably wouldn't rely on anonymous execution for specific scenarios (one of them being this case). Reason being I was getting the BLOB is not a valid UTF-8 string
error in anonymous execution which is contradicting your observation. Further, I tried to refer to an incorrect nested file name and I kept getting the same error, which leads me to believe that page reference object created had not even found the correct file and was giving misleading errors. You may encounter this in anonymous execution if you tried a different file name.
Following code snippet should be the right way to access the static resource JSON content as string.
PageReference pageRef = PageReference.forResource('EmailEditor', 'EmailEditor/Templates/Event_Base_Template.json');
PageReference contentRef = new PageReference(pageRef.getUrl().split('\\?')[0]);
System.debug('Content---' + contentRef.getContent().toString());
FYI: When I opened the file (you have posted in google drive) using notepad++, it showed up as UTF-8 encoded format. So, I believe there is nothing wrong with the file format, but just the apex code.
[SELECT Id, Body FROM StaticResource WHERE Name = 'file.json']