Comments (12)
from gsonfactory.
小伙子,我无法复制你图片上面的代码,另外你图片上面的代码不完整,请提供完整且可复现的代码到这里来。
from gsonfactory.
- assets 文件里的资源
{
"attitude": 2,
"collectTime": 1710150586000
}
- activity 代码
val json: String = getAssetsString(this, "AbnormalJson.json")
val mGson = GsonFactory.getSingletonGson()
val jsonBean = mGson.fromJson(json, aaaa::class.java)
Log.e("xxx", "" + mGson.toJson(jsonBean))
val beanToMap = mGson.fromJson(mGson.toJson(jsonBean), MutableMap::class.java)
Log.e("xxxbb", "" + beanToMap)
- aaaa 类
class aaaa {
private var attitude: Int = 0
private var collectTime: Long = 0L
override fun toString(): String {
return "aaaa(attitude=$attitude, collectTime=$collectTime)"
}
}
from gsonfactory.
from gsonfactory.
https://mikechen.cc/28914.html 用的第一种
from gsonfactory.
from gsonfactory.
from gsonfactory.
from gsonfactory.
小伙子,经过核实和验证,确实有这个问题,这是由于 Gson 内部将不指定类型的数值统一解析成 double 类型导致的,1710126441000
这个数值会被科学计数法转换成 1.71E+12
,但是不代表这样的数值有问题,这两种计数严格意义上讲都没有问题,都是相等的,只不过你更想要显示全数值的那种,而非科学计数值,解决这个问题也很简单,我在框架内部自定义了 ToNumberStrategy
接口策略,对后台返回的数值接收类型进行了优化,如果是浮点数,则用 double 类型装载,如果是整数,则用 int 类型或者 long 类型装载。
from gsonfactory.
from gsonfactory.
小伙子,你可以用上面的 aar 包试一下看问题是否被解决?
from gsonfactory.
佬,用9.6的包解决了,感谢佬的解决
from gsonfactory.
Related Issues (20)
- 能否通过getDelegateAdapter方法给所有TypeAdapter都套层代理,出错时直接跳到下一个呢 HOT 8
- [疑惑]:关于readme写的为什么gson解析后,kotlin默认值无效的问题不太对 HOT 10
- [Bug]:com.google.gson.internal.ConstructorConstructor$9.construct (ConstructorConstructor.java:262) HOT 3
- [建议]:Gson 框架转义问题 HOT 2
- [疑惑]:<init> argument 4 has type int, got null, HOT 3
- [建议]:兼容类型不匹配的情况 HOT 33
- [建议]:我想去掉这样的警告打印<init> argument 4 has type int, got null HOT 7
- [疑惑]:GsonFactory反序列化数据量大时速度有点慢 HOT 10
- [疑惑]:9.0升级9.2 HOT 2
- [Bug]:9.0升级9.2 HOT 5
- [Bug]:升级到 9.3 直接无法解析 HOT 5
- [Bug]:从 9.0 升级 9.3 出现崩溃 HOT 21
- 9.0升级9.3[Bug]: HOT 1
- [Bug]:解析出现报错 HOT 4
- 8.0版本 jitpack无法引用依赖 HOT 6
- [Bug]:开启混淆后,Kotlin的data class 内部类解析失败。 HOT 5
- [Bug]:开启混淆后,Kotlin的data class 内部类解析失败。 HOT 13
- [疑惑]:不知道怎么写标题,看描述吧 HOT 1
- [Bug]:result返回为空时出现java.lang.ClassCastException异常,具体返回格式看描述 HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gsonfactory.