You are here

public static function FeedsExJsonUtility::decodeJsonObject in Feeds extensible parsers 7

Decodes a JSON string into an object or array.

Parameters

string $json: A JSON string.

Return value

object|array A PHP object or array.

Throws

RuntimeException Thrown if the encoded JSON does not result in an array or object.

1 call to FeedsExJsonUtility::decodeJsonObject()
FeedsExJmesPath::executeContext in src/FeedsExJmesPath.inc
Returns rows to be parsed.

File

src/Json/Utility.php, line 103
Contains FeedsExJsonUtility.

Class

FeedsExJsonUtility
Various helpers for handling JSON.

Code

public static function decodeJsonObject($json) {
  $parsed = json_decode($json);
  if (!is_array($parsed) && !is_object($parsed)) {
    throw new RuntimeException(t('The JSON is invalid.'));
  }
  return $parsed;
}