Skip to content

Commit 54727fb

Browse files
committed
Add documentation of provided global functions
1 parent f16bcd7 commit 54727fb

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,48 @@ var_dump($res) //int(5)
102102

103103
```
104104

105+
## simdjson_php API
106+
107+
```php
108+
<?php
109+
/**
110+
* Similar to json_decode()
111+
*
112+
* @returns array|stdClass|string|float|int|bool|null
113+
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
114+
*/
115+
function simdjson_decode(string $json, bool $assoc = false, int $depth = 512) {}
116+
117+
/**
118+
* Returns true if json is valid.
119+
*
120+
* @returns ?bool (null if depth is invalid)
121+
*/
122+
function simdjson_is_valid(string $json, int $depth = 512) : ?bool {}
123+
124+
/**
125+
* Parses $json and returns the number of keys in $json matching the JSON pointer $key
126+
*
127+
* @returns ?bool (null if depth is invalid)
128+
*/
129+
function simdjson_key_count(string $json, string $key, int $depth = 512) : ?int {}
130+
131+
/**
132+
* Returns true if the JSON pointer $key could be found.
133+
*
134+
* @returns ?bool (null if depth is invalid, false if json is invalid or key is not found)
135+
*/
136+
function simdjson_key_exists(string $json, string $key, int $depth = 512) : ?bool {}
137+
138+
/**
139+
* Returns the value at $key
140+
*
141+
* @returns array|stdClass|string|float|int|bool|null the value at $key
142+
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
143+
*/
144+
function simdjson_key_value(string $json, string $key, bool $assoc = unknown, int $depth = unknown) {}
145+
```
146+
105147
## Edge cases
106148

107149
There are some differences from `json_decode()` due to the implementation of the underlying simdjson library. This will throw a RuntimeException if simdjson rejects the JSON.

0 commit comments

Comments
 (0)