WordPress at Your Fingertips
function is not described

WC_CLI_REST_Command::decode_json() protected WC 1.0

JSON can be passed in some more complicated objects, like the payment gateway settings array. This function decodes the json (if present) and tries to get it's value.

{} It's a method of the class: WC_CLI_REST_Command{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->decode_json( $arr );
$arr(array) (required)
Array that will be scanned for JSON encoded values.

Code of WC_CLI_REST_Command::decode_json() WC 5.9.0

protected function decode_json( $arr ) {
	foreach ( $arr as $key => $value ) {
		if ( '[' === substr( $value, 0, 1 ) || '{' === substr( $value, 0, 1 ) ) {
			$arr[ $key ] = json_decode( $value, true );
		} else {
			continue;
		}
	}
	return $arr;
}