Construct JSON path only on exceptional cases.#64
Construct JSON path only on exceptional cases.#64guidobrei wants to merge 5 commits intojamsesso:mainfrom
Conversation
magnarn
left a comment
There was a problem hiding this comment.
I think this is awesome!
Thanks for fixing it. I wish I had though of this when introducing the json path.
|
I've added additional tests to cover malformed expressions. |
|
@jamsesso any chance we could fix the issue soon? |
|
@jamsesso any updates? |
|
I imagine you’re also interested in the library’s performance, so you might be interested to know that I created a fork based on this branch, where I further improved the code by using Java’s internal compiler to translate the JSON rules into Java classes, which allowed me to achieve a 3- to 8-fold performance increase (in terms of execution speed). The new library is compatible with the old API, so you only need to change the groupId of the dependency in your project. So my repo is at : https://github.com/gzsombor/json-logic-java |
This pull request addresses issue #63: Excessive object and memory allocations from string format operations during JSON logic evaluation.
Summary of Improvements
jsonPathConstruction:Now,
jsonPathis built only when exceptions are thrown, not on every evaluation step.String.format:Frequent string formatting—previously responsible for a large portion of memory allocation—is now minimized.
Refactored string handling within the evaluation logic for improved efficiency.
Memory profiles should reflect reduced object churn and overall improved allocation patterns.
The public interfaces have not been changed. The change should not break any dependent library.
Benefits
Dramatically reduces allocations related to string operations, easing runtime memory pressure.
Faster evaluations due to fewer expensive object and string operations.
Enhanced library stability and efficiency under heavy or high-throughput usage.
jsonPathremains available for error handling and diagnostics, but is computed only as needed.