New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapl.excludeFilter 对多个path的处理错误 #322
Comments
你这样修改是会有问题的 |
之所以会出你的修改会有问题, 是因为过滤, 需要考虑到一个问题: {name:'nutz', age:12, address:[{area:1,name:'abc'},{area:2,name:'123'}]} 其中address[]的值等于[{area:1,name:'abc'},{area:2,name:'123'}], 你的方法只过滤了address[].area, 却没有过滤address[]会导致address[]的值覆盖本身已经过滤的address[].area |
嗯,这方面我倒是没有考虑到。不过我的实现会导致 {name:'nutz', name2:'nutz2',age:12, address:[{area:1,name:'abc'},{area:2,name:'123'}]} 对 {"name"} 的过滤之后把 name 和 name2 都过滤掉。从这个角度来讲我犯了个挺严重的错误。 话说对它做 {"address[].area", "address"} 过滤的结果应该是什么呢? |
上面那个应该返回 {"age":12,"name":"nutz","name2":"nutz2"} 因为, address是一个对象的key, 而address[].area表示的是数组下面的一个路径引用, address >= address[] |
为了区别list与map所以才会在list的key上面加上'[]', 但是如果把address看成一个值的key的话, 就完全不用加'[]', 因为address是对 [{area:1,name:'abc'},{area:2,name:'123'}] 的引用 |
对 Mapl.excludeFilter() 的文档中给出这样的例子:
但实际上无法得出预期的结果:
反而,在1.b.45中得到的是这样的结果:
参见 https://github.com/biggates/nutz/commit/9dbed30d53dd7c077a5cc359af6b19aa4f96207b
The text was updated successfully, but these errors were encountered: