提问人:Ömer 提问时间:7/4/2023 最后编辑:Ömer 更新时间:7/29/2023 访问量:364
无法从字符串中反序列化“java.lang.Long”类型的值,而不是有效的 Long 值
Cannot deserialize value of type `java.lang.Long` from String not a valid Long value
问:
我有一个活动,该活动在我的 Coins 类中运行一个函数。我正在尝试将下面的代码转换为 Kotlin 并运行它。
fun timeRequest() {
GlobalScope.launch(Dispatchers.IO) {
val tickerStatistics = client.get24HrPriceStatistics("NEOETH")
withContext(Dispatchers.Main) {
println(tickerStatistics.lastPrice)
}
}
}
但是我有一个错误,如下所示:
Cannot deserialize value of type `java.lang.Long` from String "0.09700000": not a valid Long value
我想这是关于选角问题。即使我尝试转换
override fun doInBackground(vararg params: Void?): Long
自
override fun doInBackground(vararg params: Void?): Float
它什么也改变不了。
theLastTime
var 很长,但错误指向下面的那行
var theLastTime = client.getCandlestickBars("NEOETH", CandlestickInterval.WEEKLY)[0].openTime
返回类型如下
[Candlestick[openTime=1506297600000,open=0.09700000,high=0.12000100,low=0.05500000,close=0.11986900,volume=25709.37000000,closeTime=1506902399999,quoteAssetVolume=2649.80091051,numberOfTrades=2435,takerBuyBaseAssetVolume=10520.59000000,takerBuyQuoteAssetVolume=1101.94985388], ...]
您可以在此处检查更多内容
CandleStick 库位于下方
package com.binance.api.client.domain.market;
import com.binance.api.client.constant.BinanceApiConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import org.apache.commons.lang3.builder.ToStringBuilder;
@JsonFormat(
shape = Shape.ARRAY
)
@JsonPropertyOrder
@JsonIgnoreProperties(
ignoreUnknown = true
)
public class Candlestick {
private Long openTime;
private String open;
private String high;
private String low;
private String close;
private String volume;
private Long closeTime;
private String quoteAssetVolume;
private Long numberOfTrades;
private String takerBuyBaseAssetVolume;
private String takerBuyQuoteAssetVolume;
public Candlestick() {
}
public Long getOpenTime() {
return this.openTime;
}
public void setOpenTime(Long openTime) {
this.openTime = openTime;
}
public String getOpen() {
return this.open;
}
public void setOpen(String open) {
this.open = open;
}
public String getHigh() {
return this.high;
}
public void setHigh(String high) {
this.high = high;
}
public String getLow() {
return this.low;
}
public void setLow(String low) {
this.low = low;
}
public String getClose() {
return this.close;
}
public void setClose(String close) {
this.close = close;
}
public String getVolume() {
return this.volume;
}
public void setVolume(String volume) {
this.volume = volume;
}
public Long getCloseTime() {
return this.closeTime;
}
public void setCloseTime(Long closeTime) {
this.closeTime = closeTime;
}
public String getQuoteAssetVolume() {
return this.quoteAssetVolume;
}
public void setQuoteAssetVolume(String quoteAssetVolume) {
this.quoteAssetVolume = quoteAssetVolume;
}
public Long getNumberOfTrades() {
return this.numberOfTrades;
}
public void setNumberOfTrades(Long numberOfTrades) {
this.numberOfTrades = numberOfTrades;
}
public String getTakerBuyBaseAssetVolume() {
return this.takerBuyBaseAssetVolume;
}
public void setTakerBuyBaseAssetVolume(String takerBuyBaseAssetVolume) {
this.takerBuyBaseAssetVolume = takerBuyBaseAssetVolume;
}
public String getTakerBuyQuoteAssetVolume() {
return this.takerBuyQuoteAssetVolume;
}
public void setTakerBuyQuoteAssetVolume(String takerBuyQuoteAssetVolume) {
this.takerBuyQuoteAssetVolume = takerBuyQuoteAssetVolume;
}
public String toString() {
return (new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)).append("openTime", this.openTime).append("open", this.open).append("high", this.high).append("low", this.low).append("close", this.close).append("volume", this.volume).append("closeTime", this.closeTime).append("quoteAssetVolume", this.quoteAssetVolume).append("numberOfTrades", this.numberOfTrades).append("takerBuyBaseAssetVolume", this.takerBuyBaseAssetVolume).append("takerBuyQuoteAssetVolume", this.takerBuyQuoteAssetVolume).toString();
}
}
我怎样才能得到这个openTime值而不会出错?
答: 暂无答案
评论
Long
Long
Double
0
)"0.09700000"