mirror of
https://github.com/halaxa/json-machine.git
synced 2025-01-17 13:08:16 +01:00
Fixed guzzle example
This commit is contained in:
parent
1c70b6cd84
commit
1c02d8e761
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.idea
|
||||
/vendor/
|
||||
composer.lock
|
||||
|
@ -18,7 +18,8 @@
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*"
|
||||
"phpunit/phpunit": "*",
|
||||
"guzzlehttp/guzzle": "^6"
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4": {"JsonMachine\\": "src/"}
|
||||
|
@ -6,6 +6,6 @@ $client = new \GuzzleHttp\Client();
|
||||
$respose = $client->request('GET', 'https://httpbin.org/anything?key=value');
|
||||
// Gets PHP stream resource from Guzzle stream
|
||||
$phpStream = \GuzzleHttp\Psr7\StreamWrapper::getResource($respose->getBody());
|
||||
$result = iterator_to_array(\JsonMachine\JsonMachine::fromStream($phpStream));
|
||||
|
||||
assert($result['args'] == ['key' => 'value']);
|
||||
foreach (\JsonMachine\JsonMachine::fromStream($phpStream) as $key => $value) {
|
||||
var_dump([$key, $value]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user