This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PayPal-PHP-SDK/lib/PayPal/Validation/JsonValidator.php
japatel 0cb302326a Enabled Payment Experience
- Updated Api to enabled Payment Experience
- Updated Tests and Samples
- Added Json Validator
- Ability for PPModel to return array of self objects
2014-10-13 12:00:31 -05:00

29 lines
603 B
PHP

<?php
namespace PayPal\Validation;
/**
* Class JsonValidator
*
* @package PayPal\Validation
*/
class JsonValidator
{
/**
* Helper method for validating if string provided is a valid json.
*
* @param string $string String representation of Json object
* @return bool
*/
public static function validate($string)
{
json_decode($string);
if (json_last_error() != JSON_ERROR_NONE) {
//Throw an Exception for string or array
throw new \InvalidArgumentException("Invalid JSON String");
}
return true;
}
}