WC_CLI_REST_Command::decode_json()
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.
Метод класса: WC_CLI_REST_Command{}
Хуков нет.
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->decode_json( $arr );
- $arr(массив) (обязательный)
- Array that will be scanned for JSON encoded values.
Код WC_CLI_REST_Command::decode_json() WC CLI REST Command::decode json WC 9.6.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; }