Skip to content
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

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

Closed
noear opened this issue May 21, 2024 · 19 comments
Closed

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

noear opened this issue May 21, 2024 · 19 comments
Labels
enhancement New feature or request fixed
Milestone

Comments

@noear
Copy link
Contributor

noear commented May 21, 2024

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

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

@noear noear added the enhancement New feature or request label May 21, 2024
@noear
Copy link
Contributor Author

noear commented May 21, 2024

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

@wenshao
Copy link
Member

wenshao commented May 21, 2024

 public void config(Feature feature, boolean state) 

用这个不可以么?

@noear
Copy link
Contributor Author

noear commented May 21, 2024

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

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

@wenshao
Copy link
Member

wenshao commented May 21, 2024

JSON.config

这个是重置全局默认值的

@noear
Copy link
Contributor Author

noear commented May 21, 2024

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

应用场景是:

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

@wenshao
Copy link
Member

wenshao commented May 22, 2024

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 wenshao added this to the 2.0.51 milestone May 22, 2024
@wenshao wenshao added the fixed label May 22, 2024
@noear
Copy link
Contributor Author

noear commented May 22, 2024

感谢!

@noear
Copy link
Contributor Author

noear commented May 22, 2024

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

@noear
Copy link
Contributor Author

noear commented May 22, 2024

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

JSONFactory.defaultWriterFeatures
JSONFactory.defaultReaderFeatures

@noear
Copy link
Contributor Author

noear commented May 23, 2024

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

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

@wenshao
Copy link
Member

wenshao commented May 24, 2024

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

@noear
Copy link
Contributor Author

noear commented May 24, 2024

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

@noear
Copy link
Contributor Author

noear commented May 24, 2024

JSONFactory.defaultWriterFeatures
JSONFactory.defaultReaderFeatures

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

@noear
Copy link
Contributor Author

noear commented May 24, 2024

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

@noear
Copy link
Contributor Author

noear commented May 27, 2024

@wenshao 还差两个函数啊:)

@wenshao
Copy link
Member

wenshao commented May 28, 2024

@noear 你帮提交个PR?

@noear
Copy link
Contributor Author

noear commented May 28, 2024

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

@noear
Copy link
Contributor Author

noear commented May 28, 2024

pr 提交了

@wenshao
Copy link
Member

wenshao commented Jun 1, 2024

@wenshao wenshao closed this as completed Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed
Projects
None yet
Development

No branches or pull requests

2 participants