简体   繁体   中英

Jackson stream parser position

I am building a tool to parse huge JSON around 1GB. In that logic, I am creating JsonParser object keep reading till it reaches expected JsonToken . Now I create another JsonParser (called child), which should be starting from previous JsonParser token position without much overhead. Is there a way to do that in JasonParser API for that? I am using skipChildren() , which is also taking time in my scenario.

You can try to call releaseBuffered(...) to get the data that are read but not consumed by the parser, and then prepend these data to the input stream ( getInputSource() ) to somehow parse the resulting stream (one way to do this might be to use an input stream that supports marks when constructing the parser).

However, since you're already using a stream based API, you probably won't get better performance than with skipChildren() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM