WPDev.one
Core Function
View Source on Trac ↗

wp_json_encode()

wp_json_encode( mixed $value, mixed $flags = 0, mixed $depth = 512 )

Encodes a variable into JSON, with some confidence checks.

Parameters 2 required

Name / Type Description
$value
mixed

Variable (usually an array or object) to encode as JSON.

Required
$flags
int

Optional. Options to be passed to json_encode(). Default 0.

int

$depth Optional. Maximum depth to walk through $value. Must be greater than 0. Default 512.

Required

Return Value

((string)
| false) The JSON encoded string, or false if it cannot be encoded.

Function Information

Since Version
4.1.0
Source File
wp-includes/functions.php
Advertisement