Skip to content

Commit e41b22a

Browse files
authored
chore: add array casting to README (#402)
1 parent 958938b commit e41b22a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,22 @@ $jwks = ['keys' => []];
203203
JWT::decode($payload, JWK::parseKeySet($jwks));
204204
```
205205

206+
Miscellaneous
207+
-------------
208+
209+
#### Casting to array
210+
211+
The return value of `JWT::decode` is the generic PHP object `stdClass`. If you'd like to handle with arrays
212+
instead, you can do the following:
213+
214+
```php
215+
// return type is stdClass
216+
$decoded = JWT::decode($payload, $keys);
217+
218+
// cast to array
219+
$decoded = json_decode(json_encode($decoded), true);
220+
```
221+
206222
Changelog
207223
---------
208224

0 commit comments

Comments
 (0)