decode() public static méthode

Decodes a JSON string, or throws JsonDecodeException on failure
public static decode ( string $string, boolean $asArray = false ) : mixed
$string string
$asArray boolean
Résultat mixed
 public function handle($data)
 {
     $method = $data['method'];
     $restData = Json::decode($data['rest_data']);
     $class = '\\Tests\\MockSugarServer\\Action\\' . Strings::underscoreToCamelCase($method);
     $action = new $class($restData);
     return $action->process()->response();
 }
Exemple #2
0
 /**
  * @return array
  */
 public function toJsonArray()
 {
     return ['name' => $this->name, 'params' => Json::decode($this->params)];
 }
 public function getRenderedJsonAsArray()
 {
     return Json::decode($this->getActualContent(), true);
 }
Exemple #4
0
 /**
  * @test
  * @dataProvider invalidJson
  * @param string $invalidJson
  */
 public function shouldThrowOnInvalidJson($invalidJson)
 {
     // when
     try {
         Json::decode($invalidJson);
         $this->assertTrue(false);
     } catch (JsonDecodeException $e) {
     }
 }
Exemple #5
0
 private static function _jsonParameters($content)
 {
     if (Strings::equalsIgnoreCase(ContentType::value(), 'application/json')) {
         return Arrays::toArray(Json::decode($content, true));
     }
     return false;
 }