true if the input is valid JSON; false with err populated otherwise.bool isValidJSON(const(char)[] input, out JsonError err, JsonPolicy policy = JsonPolicy.init) @safeValidate JSON text without building a value tree.
This function performs lexer-based validation of JSON syntax, checking for:
This is faster than full parsing when you only need to verify syntax.
input | JSON text to validate. |
err | Output parameter for error information on failure. |
policy | Policy controlling validation behavior (only maxDepth is used). |
true if the input is valid JSON; false with err populated otherwise.import ddn.data.json : isValidJSON, JsonError;
JsonError err;
assert(isValidJSON(`{"a":1,"b":[2,3]}`, err));
assert(!isValidJSON(`{invalid}`, err));bool isValidJSON(const(char)[] input) @safeConvenience overload that validates JSON without returning error details.
input | JSON text to validate. |
true if the input is valid JSON; false otherwise.