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

Scala开发Flink代码时使用fastjson2导致了type mismatch #110

Closed
2309859381 opened this issue Apr 29, 2022 · 2 comments
Closed

Scala开发Flink代码时使用fastjson2导致了type mismatch #110

2309859381 opened this issue Apr 29, 2022 · 2 comments

Comments

@2309859381
Copy link

2309859381 commented Apr 29, 2022

如标题所述。我想把一个使用fastjson1运行正常的代码升级到fastjson2,发现会导致类型丢失。
代码如下:
.map(y => { val gear:Int = 0 y.put("gear", gear) y })
会报出
the result type of an implicit conversion must be more specific than Object type mismatch; found : Int required: Object x.put("gear", gear)
观察源码后发现是因为升级后的JSONObject使用的put方法产生了变化,从重写的put方法变成了完全继承HashMap的put方法,中间有一些变化导致了类型丢失的问题。本人技术有限,没有发现更深层次的问题所在。但是似乎还是采用fastjson1那种重写Map的put方法对scala的用户更友好一些。

@wenshao
Copy link
Member

wenshao commented Apr 30, 2022

我对scalar也不了解,还在学习过程中,会考虑兼容的,需要一些时间,谢谢你的支持。

@louisjiang
Copy link

建议JSONObject 继承LinkedHashMap加上泛型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants