Class ResultJsonConverter
java.lang.Object
com.amalgamasimulation.studies.result.ResultJsonConverter
Class for converting between
Result objects and JSON representations.
Provides methods for serializing Result objects to JSON strings and deserializing JSON strings
back to SimulationRunResult objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertJsonToResult(String json) Converts a JSON string back to aSimulationRunResultobject.convertResultToJson(Result result) Converts aResultobject to its JSON string representation.
-
Constructor Details
-
ResultJsonConverter
public ResultJsonConverter()
-
-
Method Details
-
convertResultToJson
Converts aResultobject to its JSON string representation.- Parameters:
result- the Result object to convert- Returns:
- JSON string representation of the Result object
- Throws:
IllegalStateException- if the conversion fails due to:- IO errors during JSON generation
- Presence of null values in the Result object
-
convertJsonToResult
Converts a JSON string back to aSimulationRunResultobject.- Parameters:
json- the JSON string to parse- Returns:
- the reconstructed SimulationRunResult object
- Throws:
IllegalStateException- if the parsing fails due to:- Malformed JSON input
- IO errors during parsing
-