[FEATURE]scala语言项目在编译时报错
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 请描述您的需求或者改进建议
当在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")
```
Contributor guide
Research direction
Start by reproducing the reported Scala snippet and inspect JSONObject's existing put methods and key/value type declarations. The change is done when numeric and string values can be passed from Scala without the implicit-conversion error while existing Java usage remains compatible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, scala
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100