JSON Validate

You can check if a json is valid or not

Sometimes you may need to inspect and validate JSON strings coming from APIs or Front-end applications. Using the method isJson() will output if your string is a valid json.

$movies = Http::get('https://api.tvmaze.com/search/people?q=lauren');
        
ds($movies->body())->isJson()
    ->label('Valid JSON');

ds('{"}')->isJson()
    ->label('Invalid JSON');
JSON Validate

Last updated