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

JSON日志显示问题 #477

Closed
asker517 opened this issue Jan 18, 2024 · 2 comments
Closed

JSON日志显示问题 #477

asker517 opened this issue Jan 18, 2024 · 2 comments

Comments

@asker517
Copy link

框架中的日志模块在JSONStringer处理过程中如果是double或者float类型的数据,可能会导致看到的日志和实际返回的response有偏差,譬如服务器返回的是20.00,经过处理后会导致显示成20,可能是以下代码处理导致的

  this.out.append(JSONObject.numberToString((Number)value));

这里是否可以考虑优化一下展示最原始的服务器返回数据呢

@liujingxing
Copy link
Owner

对的,JSONObject.numberToString(Number)方法内部会对数据自动抹0,即使不使用该方法,在字符串转JSONObject对象的时候,对于double类型数据,也只会保留1个0,如:20.0,所以,解决这个问题,就需要自己写一套json数据解析的框架,不值的,可以考虑非格式化数据,此时就会原样输出

@asker517
Copy link
Author

感谢大佬 也倒不是啥大问题,原因是同事说返回的数据中又小数位.00...我很自信的看日志中是整数位没有.00的...所以排查出这个点儿

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

2 participants