Skip to content

Commit

Permalink
[skip ci] Document changes to exceptions in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TysonAndre committed Oct 14, 2022
1 parent 4811e5b commit ad454b7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ var_dump($res) //int(5)

```php
<?php

/**
* Similar to json_decode()
*
* @return array|stdClass|string|float|int|bool|null
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
* @throws SimdJsonException for invalid JSON
* (or document over 4GB, or out of range integer/float)
*/
function simdjson_decode(string $json, bool $assoc = false, int $depth = 512) {}

Expand All @@ -125,23 +127,39 @@ function simdjson_is_valid(string $json, int $depth = 512) : ?bool {}
* Parses $json and returns the number of keys in $json matching the JSON pointer $key
*
* @return ?int (null if depth is invalid)
* @throws SimdJsonException for invalid JSON
* (or document over 4GB, or out of range integer/float)
*/
function simdjson_key_count(string $json, string $key, int $depth = 512) : ?int {}

/**
* Returns true if the JSON pointer $key could be found.
*
* @return ?bool (null if depth is invalid, false if json is invalid or key is not found)
* @throws SimdJsonException for invalid JSON
* (or document over 4GB, or out of range integer/float)
*/
function simdjson_key_exists(string $json, string $key, int $depth = 512) : ?bool {}

/**
* Returns the value at $key
*
* @return array|stdClass|string|float|int|bool|null the value at $key
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
* @throws SimdJsonException for invalid JSON
* (or document over 4GB, or out of range integer/float)
*/
function simdjson_key_value(string $json, string $key, bool $assoc = unknown, int $depth = unknown) {}

/**
* An error thrown by simdjson when processing json.
*
* The error code is available as $e->getCode().
* This can be compared against the `SIMDJSON_ERR_*` constants.
*
* Before simdjson 2.1.0, a regular RuntimeException with an error code of 0 was thrown.
*/
class SimdJsonException extends RuntimeException {
}
```

## Edge cases
Expand Down

0 comments on commit ad454b7

Please sign in to comment.