false]) { $data = trim($data); // Because developers are clearly not validating their data before pushing it into a Registry, we'll do it for them if (empty($data)) { return new \stdClass; } $decoded = json_decode($data); // Check for an error decoding the data if ($decoded === null && json_last_error() !== JSON_ERROR_NONE) { // If it's an ini file, parse as ini. if ($data !== '' && $data[0] !== '{') { return Factory::getFormat('Ini')->stringToObject($data, $options); } throw new \RuntimeException(sprintf('Error decoding JSON data: %s', json_last_error_msg())); } return (object) $decoded; } }