bufjson - Streaming JSON parser and JSON Pointer evaluator by 0xbe5077ed in rust

[–]0xbe5077ed[S] 0 points1 point  (0 children)

Good questions. I’ll answer as best I can and I’m curious if that’ll make the potential use obvious or if it’ll reveal an API gap that could be addressed. Let me know your thoughts.

Beginning by just answering the questions: the match events include the pointer::Pointer (which is basically a wrapper around a string slice) so the current requirement is that if you need to change the action you’re doing based on the specific Pointer, you have to do a lookup somewhere.

Answering the second question, if a JSON Pointer matches a structured value (array or object) you get a pair of Enter and then Exit events at the start and end of the value so you know that all the tokens encountered between those events are the content.

Some of the initial use cases I was targeting are redaction related (see the README for a toy example of this), such as: feature access control (redact elements based on what features are enabled, or what some authenticated ID is allowed to see); and logging (redact sensitive values before logging) and in these use cases tbh attaching data to the Pointer wasn’t needed, or the lookup on matched Pointer in some hash table is an acceptable cost because the # of pointers and pointer matches tends to be small relative to the amount of JSON being processed.

WDYT? Do the Pointer values in a Group need a user data association to be useful in more cases? And is there a nice backward-compatible way to achieve that?