wp_json_encode ( $data, $options = 0, $depth = 512 )

  • (mixed) data Variable (usually an array or object) to encode as JSON.
  • (int) options Optional. Options to be passed to json_encode(). Default 0.
  • (int) depth Optional. Maximum depth to walk through $data. Must be greater than 0. Default 512.
  • (string|false) The JSON encoded string, or false if it cannot be encoded.
Defined at:
Change Log:
  • 5: .


Encodes a variable into JSON, with some sanity checks.

Related Functions

wp_json_file_decode, wp_send_json_error, wp_is_json_media_type, wp_is_json_request, wp_encode_emoji

Top Google Results

User discussions

wpseek mobile