Package com.structurizr.util
Class WorkspaceUtils
java.lang.Object
com.structurizr.util.WorkspaceUtils
Some utility methods related to workspaces.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.structurizr.Workspace
Converts the specified JSON string to a Workspace instance.static com.structurizr.Workspace
loadWorkspaceFromJson
(File file) Loads a workspace from a JSON definition saved as a file.static void
printWorkspaceAsJson
(com.structurizr.Workspace workspace) Prints a workspace as JSON to stdout - useful for debugging purposes.static void
saveWorkspaceToJson
(com.structurizr.Workspace workspace, File file) Saves a workspace to a JSON definition as a file.static String
toJson
(com.structurizr.Workspace workspace, boolean indentOutput) Serializes the specified workspace to a JSON string.
-
Constructor Details
-
WorkspaceUtils
public WorkspaceUtils()
-
-
Method Details
-
loadWorkspaceFromJson
Loads a workspace from a JSON definition saved as a file.- Parameters:
file
- a File representing the JSON definition- Returns:
- a Workspace object
- Throws:
Exception
- if something goes wrong
-
saveWorkspaceToJson
public static void saveWorkspaceToJson(com.structurizr.Workspace workspace, File file) throws Exception Saves a workspace to a JSON definition as a file.- Parameters:
workspace
- a Workspace objectfile
- a File representing the JSON definition- Throws:
Exception
- if something goes wrong
-
printWorkspaceAsJson
public static void printWorkspaceAsJson(com.structurizr.Workspace workspace) Prints a workspace as JSON to stdout - useful for debugging purposes.- Parameters:
workspace
- the workspace to print
-
toJson
public static String toJson(com.structurizr.Workspace workspace, boolean indentOutput) throws Exception Serializes the specified workspace to a JSON string.- Parameters:
workspace
- a Workspace instanceindentOutput
- whether to indent the output (prettify)- Returns:
- a JSON string
- Throws:
Exception
- if something goes wrong
-
fromJson
Converts the specified JSON string to a Workspace instance.- Parameters:
json
- the JSON definition of the workspace- Returns:
- a Workspace instance
- Throws:
Exception
- if the JSON can not be deserialized
-