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

Supply an OutputStream to a SurfingConfiguration #50

Open
arenger opened this issue Apr 25, 2019 · 2 comments
Open

Supply an OutputStream to a SurfingConfiguration #50

arenger opened this issue Apr 25, 2019 · 2 comments

Comments

@arenger
Copy link

arenger commented Apr 25, 2019

First: Good job with JsonSurfer! It's a helpful tool, for sure.

I am looking for a way to read from a large JSON file in a streaming fashion and write an excerpt from that file to a new file in a streaming fashion. The onValue method of the JsonPathListener receives an Object which was obtained in a streaming manner. This is great, but at that point the full Object is loaded in memory. Would it be possible to specify an OutputStream to a SurfingConfiguration, such that the matching portions of the incoming file could be written to the stream instead of memory?

Actually, I really need a different OutputStream for every excerpt that is matched by the specified JSON Path. Perhaps a new SurfingConfiguration.setStreamHandler method would receive a new OutputStreamHandler interface that two methods: OutputStream onNewOutput(ParsingContext context) and void end(OutputStream out)... or something. There are a few ways to do it, I'm sure.

Maybe there is already support for something like this. I looked but couldn't find any.

@wanglingsong
Copy link
Owner

This feature would require modification to jsurfer-core, probably need to implement a new kind of JsonCollector which to be inserted into the dispatcher.
Tips here: https://github.com/jsurfer/JsonSurfer/blob/master/jsurfer-core/src/main/java/org/jsfr/json/SurfingContext.java#L79

If you are interested, feel free to contribute. I'm currently working another issue regarding JsonPath filter during my limited free time

@arenger
Copy link
Author

arenger commented Apr 26, 2019

I certainly understand the limited free time. No problem. This issue isn't urgent, currently, but if it becomes urgent I might look into contributing to the project. Thanks.

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

2 participants