Bobbey Posted January 19, 2021 Share Posted January 19, 2021 (edited) I am having an issue with writing files try { log("Autosaving " + data.size() + " properties to " + getDirectoryData() + "osbot-anims.json"); String jsonFormat = gson.toJson(data); FileWriter fw = new FileWriter(new File(getDirectoryData() + "osbot-anims.json")); fw.write(jsonFormat); fw.flush(); fw.close(); } catch (Exception e) { log(e.getMessage()); e.printStackTrace(); } gives output [INFO][Bot #1][01/19 06:16:47 PM]: Autosaving 3 properties to C:\Users\Mark\OSBot\Data\osbot-anims.json [INFO][Bot #1][01/19 06:16:47 PM]: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") Edited January 19, 2021 by Bobbey Quote Link to comment Share on other sites More sharing options...
Jarl Posted January 19, 2021 Share Posted January 19, 2021 I did some quick googling and I think the issue is with gson using reflection. My guess is osbot won't let you use reflection, so you can try to google how to use gson without reflection. 1 Quote Link to comment Share on other sites More sharing options...
Bobbey Posted January 19, 2021 Author Share Posted January 19, 2021 Now I have to manually deserialize my data. Quote Link to comment Share on other sites More sharing options...
Jarl Posted January 19, 2021 Share Posted January 19, 2021 Google "gson avoid reflection" First result on stack exchange should work, but I cannot guarantee you won't run into any other issues. Quote Link to comment Share on other sites More sharing options...
Bobbey Posted January 19, 2021 Author Share Posted January 19, 2021 (edited) 4 minutes ago, Jarl said: Google "gson avoid reflection" First result on stack exchange should work, but I cannot guarantee you won't run into any other issues. I just found out that the library you linked actually works as well String jsonFormat = new JSONObject(data).toString(); So nvm my crying Edited January 19, 2021 by Bobbey 1 Quote Link to comment Share on other sites More sharing options...