Git Product home page Git Product logo

Comments (1)

wI2L avatar wI2L commented on June 9, 2024

A similar question was raised in issue #8, about the behavior of the AllowList/DenyList options.

Originally, in an earlier version, only top-levels fields were concerned by those options: 94e9fa2#diff-e66fb2b3e2ed56aa1614ff2ff129bfd9c48111d3ec9e222e196ec18022750eb4R201

The implementation pre-computed the level of a key, and it was used to determine if it should be concerned by the option. I'm thinking that we could bring back that behavior, and update the options to specify the maximum level for keys that should be concerned, like so:

AllowList(fields []string, maxLevel int)

In terms of performance, this would require to simply check the level of a key with the maximum level of the option.


Regarding your proposal, I'm not sure I fully understand what you suggest. Do you imply that any types marshalled with jettison should implement the Allower interface ? If so, how the implementation would differenciate keys of the same name but at different levels ?

Otherwise, if the interface is just an abstraction as it seems you suggest it:

The current AllowList and DenyList could be re-implemented as things that generate an Allower.

then I reckon we could do without it if the goal is to simply define the maximum levels at which keys specified by the options are allowed or denied.

If we wanted something even more flexible, say:

  • at level 1, allow only keys that match foo and bar
  • at level 2, deny all keys that match baz
  • at level 3, allow/deny everything

Then the interface could serve as an abstraction to a more complex type that would hold these information (e.g, a double map[int][]string storing the field names per priority for allowed and denied fields).

from jettison.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.