WC_CLI_REST_Command::decode_json( array $arr )

JSON can be passed in some more complicated objects, like the payment gateway settings array.


Description Description

This function decodes the json (if present) and tries to get it’s value.


Parameters Parameters

$arr

(Required) Array that will be scanned for JSON encoded values.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/cli/class-wc-cli-rest-command.php

	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;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.