Skip to content

Adding support for compiled json path + json pointer (reflection based)#2483

Merged
lemire merged 11 commits intomasterfrom
francisco/json_path_reflection
Oct 27, 2025
Merged

Adding support for compiled json path + json pointer (reflection based)#2483
lemire merged 11 commits intomasterfrom
francisco/json_path_reflection

Conversation

@FranciscoThiesen
Copy link
Member

This was asked for in #2070 . It shows an interesting way of leveraging reflection to support a real-world demand.

@lemire
Copy link
Member

lemire commented Oct 3, 2025

On my TODO to review. This looks like very impressive work.

@FranciscoThiesen FranciscoThiesen changed the title Adding support for compiled json path (reflection based) Adding support for compiled json path + json pointer (reflection based) Oct 3, 2025
@FranciscoThiesen
Copy link
Member Author

Added json pointer support as well

@lemire lemire mentioned this pull request Oct 16, 2025
@lemire
Copy link
Member

lemire commented Oct 16, 2025

@FranciscoThiesen I do not understand the reflection part of the code. What does at_pointer_compiled<User, "/name">(doc) do ?

The compile-time expression parsing is pretty clear. I imagine that the main use case is that you have the expression validated at compile time... so no runtime surprise is possible. In theory it could result in better performance in some cases, but that is unclear to me. Still, having the expression validated at compile time makes sense. Many of these expressions are compile-time constants anyhow.

What I am dubious about is the reflection... as I don't understand what it is meant to do?

@FranciscoThiesen
Copy link
Member Author

@FranciscoThiesen I do not understand the reflection part of the code. What does at_pointer_compiled<User, "/name">(doc) do ?

The compile-time expression parsing is pretty clear. I imagine that the main use case is that you have the expression validated at compile time... so no runtime surprise is possible. In theory it could result in better performance in some cases, but that is unclear to me. Still, having the expression validated at compile time makes sense. Many of these expressions are compile-time constants anyhow.

What I am dubious about is the reflection... as I don't understand what it is meant to do?

We can not only validate the path using reflection, but also generate the accessor code. (this avoids the need to parse the path at run-time and initial benchmark shows strong efficient gains, specially for longer paths).

@lemire
Copy link
Member

lemire commented Oct 27, 2025

Merging. Let us push it to the next release.

@lemire lemire merged commit 58c92d6 into master Oct 27, 2025
156 checks passed
@lemire lemire deleted the francisco/json_path_reflection branch October 27, 2025 20:52
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

Successfully merging this pull request may close these issues.

2 participants