fastjson2 icon indicating copy to clipboard operation
fastjson2 copied to clipboard

[FEATURE] 希望增加 Context::config 的“与”操作

Open noear opened this issue 1 year ago • 15 comments

JSONReader.Context::config(..) 和 JSONWriter.Context::config(..)

它们内部是 |= 操作,能不能出一个 &= 的操作?

noear avatar May 21 '24 16:05 noear

如果可以的话,希望再加个直接修改 long features 的接口,或者重置它的接口

noear avatar May 21 '24 16:05 noear

 public void config(Feature feature, boolean state) 

用这个不可以么?

wenshao avatar May 21 '24 21:05 wenshao

啊哈,看走眼了。。。这个确实可以。

那,如何想重置为默认值,有什么接口可用吗?

noear avatar May 21 '24 23:05 noear

JSON.config

这个是重置全局默认值的

wenshao avatar May 21 '24 23:05 wenshao

这个影响太大了。。。我是想重置 context 里的 long features 值。

应用场景是:

我给定了些默认的特性,但是用户不想要。用户想重置后,再添加自己的特性。

noear avatar May 21 '24 23:05 noear

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.51-SNAPSHOT/ 已经支持,请帮忙用2.0.51-SNAPSHOT版本验证 JSONReader.Context和JSONWriter.Context都已经支持setFeatures(long)方法

wenshao avatar May 22 '24 21:05 wenshao

感谢!

noear avatar May 22 '24 23:05 noear

在我这儿。算是:在默认配置后,还有一个“二次配置”的可能。

noear avatar May 22 '24 23:05 noear

还需要提供获取它们的两个函数(重置默认时用):

JSONFactory.defaultWriterFeatures
JSONFactory.defaultReaderFeatures

noear avatar May 22 '24 23:05 noear

还需要加个 jsonb 相关的接口:

JSON.parse(byte[] bytes, JSONReader.Context)

noear avatar May 23 '24 00:05 noear

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.51-SNAPSHOT/ 已经加上相关方法,请帮忙用2.0.51-SNAPSHOT版本验证

wenshao avatar May 24 '24 01:05 wenshao

谢谢。。。哎,做开源人真不容易啊:)

noear avatar May 24 '24 01:05 noear

JSONFactory.defaultWriterFeatures JSONFactory.defaultReaderFeatures

这两个,还没有对应的方法可以获取?!

noear avatar May 24 '24 14:05 noear

是不是可以添加???: JSONFactory.getDefaultReaderFeatures() JSONFactory.getDefaultWriterFeatures()

noear avatar May 24 '24 14:05 noear

@wenshao 还差两个函数啊:)

noear avatar May 27 '24 09:05 noear

@noear 你帮提交个PR?

wenshao avatar May 28 '24 02:05 wenshao

@wenshao 这两函数。。。我可以:)

noear avatar May 28 '24 02:05 noear

pr 提交了

noear avatar May 28 '24 04:05 noear

https://github.com/alibaba/fastjson2/releases/tag/2.0.51 请用新版本

wenshao avatar Jun 01 '24 10:06 wenshao