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

RFC: partial decoding #61

Open
ztellman opened this issue May 27, 2014 · 5 comments
Open

RFC: partial decoding #61

ztellman opened this issue May 27, 2014 · 5 comments
Assignees
Labels

Comments

@ztellman
Copy link
Collaborator

I made a proof of concept for this a while back, pushed a branch, and then didn't actually explain what it is: https://github.com/dakrone/cheshire/tree/field-predicate-feature

Basically, we want to be able to use the "skip children" feature in the Jackson parser. Unfortunately, it's hard to specify where to skip without some sort of schema, but schemas (typically) would require us to enumerate all the fields we want to parse, rather than use some sort of programmatic specification.

My questionable workaround for this is a predicate function which passes in the parent and child keys as it traverses the JSON structure. So for this structure:

{"a": {"b": 1}}

The predicate would first get passed [nil "a"] to check if {"b": 1} should be parsed, and then ["a" "b"] to check if the 1 should be parsed. This is an adequate solution, at best, but I can't think of an obviously better one.

The performance gains here are at best 50%, as Jackson still needs to figure out where the children nodes end. However, 50% is still pretty good. I'd be interested to hear your thoughts.

@dakrone
Copy link
Owner

dakrone commented May 27, 2014

I'll check out the branch, thanks for the reminder!

@dakrone
Copy link
Owner

dakrone commented Jul 6, 2014

@ztellman I agree that what the predicate gets passed is a little confusing, but I think for the subset of users that would find this useful, [parent key] will suffice, adding the plumbing for passing the whole parent path would probably add too much overhead to make use of the speed boost from not parsing the child.

I think this looks pretty good to me, want to add some docs for it and then submit a PR (or merge it in since you have commit access)?

@barkanido
Copy link

any progress on this @ztellman? reinventing the Clojure wrapper in another lazy JSON parse is a pain :-)

@ztellman
Copy link
Collaborator Author

Well, it's been a while, but I wasn't very happy with the approach to the predicate and ultimately didn't think it was worth it. If you'd like to pick this up and create a PR against the current codebase, please feel free.

@DeLaGuardo
Copy link

I made a PR with that feature (as far as I understand) #134

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

No branches or pull requests

4 participants