code: public static void saveWorkspaceToJson(Workspace workspace, File file) throws Exception {
          if (workspace == null) {
              throw new IllegalArgumentException("A workspace must be provided.");
          } else if (file == null) {
              throw new IllegalArgumentException("The path to a JSON file must be specified.");
          }
  
          OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
          new JsonWriter(true).write(workspace, writer);
          writer.flush();
          writer.close();
      }
docs: Saves a workspace to a JSON definition as a file.
  
  @param workspace     a Workspace object
  @param file          a File representing the JSON definition
  @throws Exception    if something goes wrong