Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigation notes for flag analogous to JSON_BIGINT_AS_STRING #76

Open
TysonAndre opened this issue Oct 1, 2022 · 1 comment
Open

Comments

@TysonAndre
Copy link
Collaborator

TysonAndre commented Oct 1, 2022

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();
TysonAndre added a commit to TysonAndre/simdjson_php that referenced this issue Oct 4, 2022
Also, this is failing to check for trailing content

Related to crazyxman#76
@TysonAndre
Copy link
Collaborator Author

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant