# LibTmux\ConvertTo-TmuxQueryJson

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/ConvertToTmuxQueryJsonCommand.cs#L8
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-convertto-tmuxqueryjson/

```
ConvertTo-TmuxQueryJson
    [-Query] <LibTmux.Query.QueryDocument>
    [<CommonParameters>]
```

[`Serialize`](/en/csharp/latest/reference/libtmux-query-json-queryjson-serialize/) a native query document.

[`Serialize`](/en/csharp/latest/reference/libtmux-query-json-queryjson-serialize/) a native query document through LibTmux.Query.Json. The returned
string uses the shared schema 2 contract. Serialization performs no tmux I/O.
Restore the document with [`New-TmuxQuery`](/en/powershell/latest/reference/libtmux-new-tmuxquery/) -Json.

### Notes

[`Tmux.QueryJsonFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/ConvertTo-TmuxQueryJson.md#notes) terminates invalid serialization.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Query.QueryDocument`: Native query documents.
- **Outputs:** `System.String`

Related APIs:

- [`New-TmuxQuery`](/en/powershell/latest/reference/libtmux-new-tmuxquery/)

## Examples

Example 1

Serialize a pane-width filter for storage or another native consumer.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/ConvertTo-TmuxQueryJson.md).

```powershell
LibTmux\New-TmuxQuery -Target Pane -Criteria @{ Width = @{ Ge = 80 } } |
    LibTmux\ConvertTo-TmuxQueryJson
```

## Parameters

- `Query` (`LibTmux.Query.QueryDocument`): The native document to serialize.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.

## Returns

`System.String`: One JSON string per document.
