simdjson_php
simdjson_php copied to clipboard
Investigation notes for flag analogous to JSON_BIGINT_AS_STRING
This may or may not be difficult with the dom parser.
Future simdjson C releases may make this easier but this functionality might not be planned for arbitrary-precision integers (only floats) - https://github.com/simdjson/simdjson/pull/1886 is in review pending manual tests and performance testing.
- See my PR comment for a note on how BIGINT might be possible in followup
https://github.com/simdjson/simdjson/issues/167 suggests it's possible with the ondemand parser, but that may be slightly slower than the dom parser?
https://github.com/simdjson/simdjson/issues/425#issuecomment-883605600 mentions this is supported in the ondemand api
We may want to take the tiny performance hit just to imitate php's behavior for numbers in json_decode()
Note that this is effectively supported now with the On Demand API and documented as such:
simdjson::ondemand::parser parser;
simdjson::padded_string docdata = R"({"value":12321323213213213213213213213211223})"_padded;
simdjson::ondemand::document doc = parser.iterate(docdata);
simdjson::ondemand::object obj = doc.get_object();
std::string_view token = obj["value"].raw_json_token();
https://github.com/TysonAndre/simdjson_php/tree/wip-ondemand-parser has incomplete changes exploring what would be needed to use ondemand instead. Some limitations make it a better idea to stay with the dom implementation - this also keeps the bindings simpler:
- Depth isn't checked automatically in ondemand (same for json_pointer)
- Can't iterate over a document multiple times
- Document isn't automatically validated, which it currently is (e.g. for simdjson_key_exists())