-
Notifications
You must be signed in to change notification settings - Fork 651
Description
I am executing a piece of java code inside Judge0 and when its done executing I am making it return a json output through stdout. I added an additional library called Gson that will serialize the output into a json format and Judge0 sends that through stdout.
My question is if I can do something like this:
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonReport = gson.toJson(report);
try (PrintWriter out = new PrintWriter("report.json")) {
out.println(jsonReport);
} catch (Exception e) {
System.err.println("Error writing output: " + e.getMessage());
}
This API is new to me so I am wondering if anyone had a solution for writing the output to a file and then extract it somehow.
The reason I want to write to file is because a user might write some System.out.println in their code and when Judge0 captures, it will be appended to our custom report and because of that serialization will break in the backend because its expecting a specific json output from stdout.