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]scala语言项目在编译时报错 #1470

Open
sinodzh opened this issue May 12, 2023 · 1 comment
Open

[FEATURE]scala语言项目在编译时报错 #1470

sinodzh opened this issue May 12, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@sinodzh
Copy link

sinodzh commented May 12, 2023

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

当在scala语言的项目中使用fastjson2的时候,如果put的值的类型是非string,会提示如下错误:

error: the result type of an implicit conversion must be more specific than AnyRef
json.put("a",1000/100)

error: the result type of an implicit conversion must be more specific than AnyRef
json.put("b",10)

error: the result type of an implicit conversion must be more specific than AnyRef
json.put("c",10.2d)

请描述你建议的实现方案

在JSONObject中重写put方法,指定输入的值是object
因为JSONObject在类的定义的时候指定了key和value的类型,这样做不影响现有的使用。

描述您考虑过的替代方案

对您考虑过的任何替代解决方案或功能的描述。

附加信息

复现代码

    val json = new JSONObject()
    json.put("a",1000/100)
    json.put("b",10)
    json.put("c",10.2d)
    json.put("d","1234")
@sinodzh sinodzh added the enhancement New feature or request label May 12, 2023
sinodzh pushed a commit to sinodzh/fastjson2 that referenced this issue May 12, 2023
@sinodzh
Copy link
Author

sinodzh commented May 12, 2023

已经提交pr

sinodzh pushed a commit to sinodzh/fastjson2 that referenced this issue May 12, 2023
sinodzh added a commit to sinodzh/fastjson2 that referenced this issue May 12, 2023
sinodzh added a commit to sinodzh/fastjson2 that referenced this issue May 13, 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
Projects
None yet
Development

No branches or pull requests

1 participant