how to utilise FilteringParserDelegate?

141 views
Skip to first unread message

Bo Ferri

unread,
Aug 3, 2015, 2:09:10 PM8/3/15
to jackson-user
Hi all,

I like to make use of FilteringParserDelegate when parsing a JSON input string and I would like to apply a JSON pointer via JsonPointerBasedFilter. So far I got it working. However, I'm struggling a bit with the result processing. I thought that I could make use of FilteringParserDelegate#getMatchCount() to retrieve the number of matches that are hit via the given JSON pointer, since I would like to process every match separately afterwards. I had a look at the implementation of FilteringParserDelegate in jackson-core 2.6.0. From my observations so far, I cannot see any usage (value assignment) of _matchCount or _allowMultipleMatches (which relates to this topic as well) in this class. Since there is no further sub class of FilteringParserDelegate nor a setter for both attributes, I'm wondering where they are utilised. Did I oversee something?

Thanks a lot in advance for all your help.

Cheers,


Bo

Tatu Saloranta

unread,
Aug 3, 2015, 2:25:19 PM8/3/15
to jackso...@googlegroups.com
Hmmh. It is possible that you have uncovered a bug here. FilteringGeneratorDelegate does update the count appropriately, and that was implemented first. But it definitely looks like updates are missing from FilteringParserDelegate. So this is a flaw. Could you file a bug for `jackson-core` at github? (also: patches are highly welcome, if you happen to see likely places where count should be updated!).

Same appears to be the case, more or less, for `_allowMultipleMatches`.

So this is a case of incomplete implementation. I think I had some concerns as to how well it could be supported for parsing side; but I should have left the parser-side configuration out of 2.6 since it has not yet been implemented. I would like to add support if feasible, however; and given that all the configuration is in place, this could happen with 2.6.x patches.

-+ Tatu +-


--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Ariens

unread,
Aug 3, 2015, 3:03:48 PM8/3/15
to Tatu Saloranta


Sent from my BlackBerry 10 smartphone on the TELUS network.
From: Tatu Saloranta
Sent: Monday, August 3, 2015 2:25 PM
Subject: Re: [jackson-user] how to utilise FilteringParserDelegate?

Bo Ferri

unread,
Aug 4, 2015, 7:08:19 AM8/4/15
to jackson-user
Hi Tatu,

thanks a lot for your reply. I will create an issue at the jackson-core github project for this.
For now I'm going with JSONPath (https://github.com/jayway/JsonPath + http://goessner.net/articles/JsonPath/), which looks like being a bit more appropriate for my intended use case (e.g. (from my observations so far) there is no "wildcard" option in JSON Pointer (but in JSONPath (which is more closely aligned to/inspired by XPath))).

Cheers,


Bo

Bo Ferri

unread,
Aug 4, 2015, 7:16:20 AM8/4/15
to jackson-user

Tatu Saloranta

unread,
Aug 4, 2015, 12:36:50 PM8/4/15
to jackson-user
Thanks!

Filters are really meant to support maximum efficiency, to filter out content at streaming speeds.
From functionality standpoint that limits operations, and it is a low-level building block in any case. So for maximum expressiveness / power, other options may make most sense.
Filtering makes most sense for things like grepping, or matching just a small sub-tree of a large content document or stream.

-+ Tatu +-

Reply all
Reply to author
Forward
0 new messages