Comments (1)
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
andbar
- 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)
- API to handler decoder? HOT 2
- durationFormat error HOT 2
- Omitting a value that marshals into `null` isn't possible? HOT 6
- Panic when marshaling maps in Go 1.18 HOT 3
- fatal error: runtime: name offset out of range HOT 4
- AllowList appear to be propagated HOT 8
- Panic when marshalling a struct with a map and a custom MarshalJSON() HOT 4
- Error when marshalling a structure with a field being an interface HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jettison.