validate()
Fast boolean check — is the input valid JSON?
Signature
php
JsonFast::validate(string $json): boolParameters
| Name | Type | Description |
|---|---|---|
$json | string | Raw JSON text to check |
Returns
true if the document parses as valid JSON; false otherwise.
No error location or repair hints — use inspect() or analyse() when you need more detail.
Examples
php
JsonFast::validate('{"ok":true}'); // true
JsonFast::validate('{not json}'); // false
JsonFast::validate(''); // falseGate processing without allocating a decoded structure:
php
if (!JsonFast::validate($payload)) {
return response()->json(['error' => 'Invalid JSON'], 400);
}
$data = JsonFast::minify($payload);