gpt4 book ai didi

android - java.lang.NumberFormatException : Invalid double: "5b80393f7fca491488980fe1" in android 异常

转载 作者:搜寻专家 更新时间:2023-11-01 08:20:09 26 4
gpt4 key购买 nike

<分区>

我有这个 Kotlin 类

class CategoryJsonData(val category: List<Category>) 
data class Category(val _id:Double, val category_name:String, val sub_category_name:String, val price:Int)

在这一行,我得到一个错误

val jsonData = gson.fromJson(body, CategoryJsonData::class.java)

当我解析这个 JSON 时

{ "_id": "5b80393f7fca491488980fe1", "category_name": "electrical", "sub_category_name": "switches meters and fuses", "price": 300 }

java.lang.NumberFormatException: Invalid double: "5b80393f7fca491488980fe1"

5b80393f7fca491488980fe1(_id) 是mongoose使用nodejs生成的。尝试访问 API 时显示此错误。

09-18 23:26:47.026 18264-18542/com.hiretheskill.skill E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.hiretheskill.skill, PID: 18264
java.lang.NumberFormatException: Invalid double: "5b80393f7fca491488980fe1"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseDouble(StringToReal.java:282)
at java.lang.Double.parseDouble(Double.java:301)
at com.google.gson.stream.JsonReader.nextDouble(JsonReader.java:909)
at com.google.gson.Gson$2.read(Gson.java:284)
at com.google.gson.Gson$2.read(Gson.java:278)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.Gson.fromJson(Gson.java:887)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.google.gson.Gson.fromJson(Gson.java:773)
at com.hiretheskill.skill.SubCategories$fetchJsonData$client$1.onResponse(SubCategories.kt:45)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com