Skip to content

Commit 9a27456

Browse files
authored
Merge pull request #91 from crazyxman/update-README
Update the README
2 parents 1a673da + 3526ec4 commit 9a27456

File tree

3 files changed

+47
-27
lines changed

3 files changed

+47
-27
lines changed

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ simdjson_php bindings for the [simdjson project](https://github.com/lemire/simdj
55
[![Build Status (Windows)](https://ci.appveyor.com/api/projects/status/github/crazyxman/simdjson_php?svg=true)](https://ci.appveyor.com/project/crazyxman/simdjson-php)
66

77
## Requirement
8-
- PHP 7 +
9-
- We support platforms like Linux or macOS
8+
9+
- PHP 7.0+ (The latest php version was 8.2 at the time of writing)
1010
- Prerequisites: g++ (version 7 or better) or clang++ (version 6 or better), and a 64-bit system with a command-line shell (e.g., Linux, macOS, freeBSD). We also support programming environments like Visual Studio and Xcode, but different steps are needed
1111

1212
## Installing
@@ -63,27 +63,29 @@ $jsonString = <<<'JSON'
6363
}
6464
JSON;
6565

66-
//Check if a JSON string is valid:
66+
// Check if a JSON string is valid:
6767
$isValid = simdjson_is_valid($jsonString); //return bool
6868
var_dump($isValid); // true
6969

70-
//Parsing a JSON string. similar to the json_decode() function but without the fourth argument
70+
// Parsing a JSON string. similar to the json_decode() function but without the fourth argument
7171
try {
72-
$parsedJSON = simdjson_decode($jsonString, true, 512); //return array|object|null. "null" string is not a standard json
72+
// returns array|stdClass|string|float|int|bool|null.
73+
$parsedJSON = simdjson_decode($jsonString, true, 512);
7374
var_dump($parsedJSON); // PHP array
7475
} catch (RuntimeException $e) {
7576
echo "Failed to parse $jsonString: {$e->getMessage()}\n";
7677
}
7778

78-
//note. "/" is a separator. Can be used as the "key" of the object and the "index" of the array
79-
//E.g. "Image/Thumbnail/Url" is ok.
80-
79+
// note. "/" is a separator. Can be used as the "key" of the object and the "index" of the array
80+
// E.g. "/Image/Thumbnail/Url" is recommended starting in simdjson 4.0.0,
81+
// but "Image/Thumbnail/Url" is accepted for now.
8182

82-
//get the value of a "key" in a json string
83-
$value = simdjson_key_value($jsonString, "Image/Thumbnail/Url");
83+
// get the value of a "key" in a json string
84+
// (before simdjson 4.0.0, the recommended leading "/" had to be omitted)
85+
$value = simdjson_key_value($jsonString, "/Image/Thumbnail/Url");
8486
var_dump($value); // string(38) "http://www.example.com/image/481989943"
8587

86-
$value = simdjson_key_value($jsonString, "Image/IDs/4", true);
88+
$value = simdjson_key_value($jsonString, "/Image/IDs/4", true);
8789
var_dump($value);
8890
/*
8991
array(1) {
@@ -92,12 +94,13 @@ array(1) {
9294
}
9395
*/
9496

95-
//check if the key exists. return true|false|null. "true" exists, "false" does not exist, "null" string is not a standard json
96-
$res = simdjson_key_exists($jsonString, "Image/IDs/1");
97+
// check if the key exists. return true|false|null. "true" exists, "false" does not exist,
98+
// throws for invalid JSON.
99+
$res = simdjson_key_exists($jsonString, "/Image/IDs/1");
97100
var_dump($res) //bool(true)
98101

99102
// count the values
100-
$res = simdjson_key_count($jsonString, "Image/IDs");
103+
$res = simdjson_key_count($jsonString, "/Image/IDs");
101104
var_dump($res) //int(5)
102105

103106
```
@@ -138,7 +141,8 @@ function simdjson_is_valid(string $json, int $depth = 512) : bool {}
138141
* @param string $json The JSON string being decoded
139142
* @param string $key The JSON pointer being requested
140143
* @param int $depth The maximum nesting depth of the structure being decoded.
141-
* @param bool $throw_if_uncountable If true, then throw SimdJsonException instead of returning 0 for JSON pointers
144+
* @param bool $throw_if_uncountable If true, then throw SimdJsonException instead of
145+
returning 0 for JSON pointers
142146
to values that are neither objects nor arrays.
143147
* @return int
144148
* @throws SimdJsonException for invalid JSON or invalid JSON pointer

package.xml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,16 @@
2020
-->
2121
<date>2022-10-19</date>
2222
<version>
23-
<release>4.0.0</release>
24-
<api>4.0.0</api>
23+
<release>4.0.1dev</release>
24+
<api>4.0.1dev</api>
2525
</version>
2626
<stability>
2727
<release>stable</release>
2828
<api>stable</api>
2929
</stability>
3030
<license uri="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</license>
3131
<notes>
32-
* Make the `SIMDJSON_ERR_*` constants case-sensitive in all PHP versions.
33-
(The code it was based on was missing the flag needed to mark constants as case sensitive before PHP 8)
34-
* Fix a bug that prevented using JSON pointer in `simdjson_key_count`, `simdjson_key_exists`, and `simdjson_key_value` with a leading slash https://www.rfc-editor.org/rfc/rfc6901.html.
35-
36-
This bug was introduced when working around test failures following a change in json pointer validation in the underlying C simdjson library.
37-
* "" in a JSON pointer continues to refer to the entire document.
38-
* "/" in a JSON pointer now properly refers to the key that is the empty string.
39-
* Continue to allow the non-standard omission of the leading "/" for compatibility with earlier PECL releases. This may be deprecated in a subsequent release.
32+
* Update the README
4033
</notes>
4134
<contents>
4235
<dir name="/">
@@ -125,6 +118,28 @@
125118
<providesextension>simdjson</providesextension>
126119
<extsrcrelease/>
127120
<changelog>
121+
<release>
122+
<date>2022-10-19</date>
123+
<version>
124+
<release>4.0.0</release>
125+
<api>4.0.0</api>
126+
</version>
127+
<stability>
128+
<release>stable</release>
129+
<api>stable</api>
130+
</stability>
131+
<license uri="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</license>
132+
<notes>
133+
* Make the `SIMDJSON_ERR_*` constants case-sensitive in all PHP versions.
134+
(The code it was based on was missing the flag needed to mark constants as case sensitive before PHP 8)
135+
* Fix a bug that prevented using JSON pointer in `simdjson_key_count`, `simdjson_key_exists`, and `simdjson_key_value` with a leading slash https://www.rfc-editor.org/rfc/rfc6901.html.
136+
137+
This bug was introduced when working around test failures following a change in json pointer validation in the underlying C simdjson library.
138+
* "" in a JSON pointer continues to refer to the entire document.
139+
* "/" in a JSON pointer now properly refers to the key that is the empty string.
140+
* Continue to allow the non-standard omission of the leading "/" for compatibility with earlier PECL releases. This may be deprecated in a subsequent release.
141+
</notes>
142+
</release>
128143
<release>
129144
<version>
130145
<release>3.0.0</release>

php_simdjson.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ BEGIN_EXTERN_C()
5151
extern zend_module_entry simdjson_module_entry;
5252
#define phpext_simdjson_ptr &simdjson_module_entry
5353

54-
#define PHP_SIMDJSON_VERSION "4.0.0"
54+
#define PHP_SIMDJSON_VERSION "4.0.1dev"
5555
/**
5656
* PHP_SIMDJSON_VERSION_ID has the same format as PHP_VERSION_ID: Major version * 10000 + Minor version * 100 + Patch version.
5757
* This is meant for use by PECL extensions that depend on simdjson.
58+
* (e.g. 4.5.6dev and 4.5.6 would be 40506)
5859
*/
59-
#define PHP_SIMDJSON_VERSION_ID 40000
60+
#define PHP_SIMDJSON_VERSION_ID 40001
6061

6162
#define SIMDJSON_SUPPORT_URL "https://github.com/crazyxman/simdjson_php"
6263

0 commit comments

Comments
 (0)