Quote CMake JSON arguments
The CMake
string(JSON)
subcommands should have the “json-string” input variable
quoted
to avoid CMake interpreting any semicolon in the JSON string as a list separator.
This avoids CMake string(JSON ...)
failures when the JSON string contains semicolons.
string sub-command JSON failed parsing json string:
Syntax error: value, object or array expected.
Example
Suppose a JSON string contains one or more values with semicolons in any value.
In that case, the JSON string should be quoted to avoid the CMake string(JSON ...)
failure.
set(json_string "{ \"key1\": 432, \"key2\": \"I like to write; my blog is about tech. \" }")
# Fails with a syntax error
string(JSON a GET ${json_string} key1)
# works as expeccted
string(JSON a GET "${json_string}" key1)
Related: CMake JSON array iteration