<?php $b = new \ebi\Browser(); $b->vars('abc', 123); $b->vars('def', 456); $b->do_json(url('index::http_method_vars') . '?xyz=789'); eq('{"abc":123,"def":456}', \ebi\Json::decode($b->body())['result']['raw']); $b = new \ebi\Browser(); $b->vars('abc', 123); $b->vars('def', 456); $b->do_post(url('index::http_method_vars') . '?xyz=789'); eq(123, $b->json('result/post/abc')); eq(456, $b->json('result/post/def')); try { $b->json('result/post/xyz'); fail(); } catch (\ebi\exception\NotFoundException $e) { } $b = new \ebi\Browser(); $b->vars('abc', 123); $b->vars('def', 456); $b->do_get(url('index::http_method_vars') . '?xyz=789'); eq(123, $b->json('result/get/abc')); eq(456, $b->json('result/get/def')); eq(789, $b->json('result/get/xyz'));
<?php eq(10, \ebi\Json::decode('10')); eq(['abc' => 10], \ebi\Json::decode('{"abc":10}')); try { \ebi\Json::decode('{"abc"10}'); fail(); } catch (\ebi\exception\InvalidArgumentException $e) { } eq('{"abc":10}', \ebi\Json::encode(['abc' => 10])); eq('{"def":"aaa","ghi":100,"jkl":null}', \ebi\Json::encode(new \test\Json())); $obj = new \test\Json(); $obj->jkl(new \test\Json()); eq('{"def":"aaa","ghi":100,"jkl":{"def":"aaa","ghi":100,"jkl":null}}', \ebi\Json::encode($obj));