I am using one JVM to prepare inputs for a simulation in another JVM. The simulation uses a C++ DLL, and when that DLL crashes, it takes the JVM with it. Running it in a separate JVM protects the first JVM from crashing as well. I prepare the simulation inputs as a JSON string in the first JVM and pass it to the second using ProcessBuilder. However, when passing a standard JSON, ProcessBuilder strips away the double quotes, e.g., "count": 5 becomes count: 5, which results in an invalid JSON that cannot be parsed in the main(String[] args) method. The workaround is to use jsonStr.replace("\"", "\\\"")
before passing jsonStr to ProcessBuilder.
C++ and MATLAB Simulink tips for HWIL simulation software engineers
Friday, July 12, 2024
Passing JSON to ProcessBuilder
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment