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]能不能在jsonobject和jsonarry上加上带有为null取默认值的方法,比如getDateOrDefault(keyName,defaultValue)这样的 #1252

Closed
GeYiPeng opened this issue Mar 18, 2023 · 2 comments
Labels
enhancement New feature or request fixed
Milestone

Comments

@GeYiPeng
Copy link

请描述您的需求或者改进建议

对您想要需求或建议的清晰简洁的描述。
能不能在jsonobject和jsonarray上加上带有默认值得获取方法,比如getDateOrDefault(keyName,defaultValue)这样的,或者直接重载getDate(keyName,defaultValue)
现有的只有一个getOrDefault方法返回的是一个object很多时候无法直接使用,而且例如getInteger这样的会对一些常见类型自动转换比如字符串“111”转成int的111,尤其是getDate这个方法,现在可以将json中有个key:"2023/3/19 18:56:02"直接转成Date,getOrDefault貌似不行,有个getDateOrDefault("key",new Date())不是会方便很多吗

请描述你建议的实现方案

对您想要需求或建议的实现方案的详细描述。

描述您考虑过的替代方案

对您考虑过的任何替代解决方案或功能的描述。
替代方案的话在hutool的json,apache camel的json中都有类似的方法

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@GeYiPeng GeYiPeng added the enhancement New feature or request label Mar 18, 2023
@wenshao
Copy link
Member

wenshao commented Mar 18, 2023

可以的啊,你可以提交一个PR参与进来么?

wenshao added a commit that referenced this issue Apr 1, 2023
@wenshao wenshao added this to the 2.0.27 milestone Apr 1, 2023
@wenshao wenshao added the fixed label Apr 1, 2023
@wenshao
Copy link
Member

wenshao commented Apr 8, 2023

@wenshao wenshao closed this as completed Apr 8, 2023
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