---
title: "lzb/export_json/die"
description: "PHP filter `lzb/export_json/die` of the Lazy Blocks WordPress plugin."
url: "https://www.lazyblocks.com/docs/php-filters/lzb-export_json-die/"
source: "php-filters/lzb-export_json-die.mdx"
---
# lzb/export_json/die

Keeps `export_json()` from calling `die()`, so a test can assert on the exported JSON instead of losing the PHPUnit process.

This exists for the plugin's own test suite. A test that reaches the `die()` takes the whole runner down and PHPUnit reports a crashed process rather than the failed assertion.

## Attributes

| Name   | Type        | Description                                         |
| ------ | ----------- | --------------------------------------------------- |
| `$die` | **Boolean** | whether to terminate the request, `true` by default |

## Usage

```php title="PHP"
// In a PHPUnit test case.
add_filter( 'lzb/export_json/die', '__return_false' );

ob_start();
lazyblocks()->tools()->export_json( array( $block_id ) );
$exported = json_decode( ob_get_clean(), true );

$this->assertSame( 'lazyblock/my-block', $exported[0]['slug'] );

remove_filter( 'lzb/export_json/die', '__return_false' );
```

The filter runs after the `Content-disposition` headers and the JSON body have already been written. Returning a falsy value on a live site therefore does not cancel the download, it lets the admin page continue rendering and appends its HTML to the end of the downloaded `.json` file. Leave the default `true` outside of tests.

## Documentation Index
> Fetch the complete documentation index at: https://www.lazyblocks.com/llms.txt
> Fetch every page in a single file at: https://www.lazyblocks.com/llms-full.txt
