我有一个扩展Serializable的数据类。 我有使用对象数据字段设置的somme变量。
我的数据类看起来像这样
data class AvailablePollResponseModel(
@field:JsonProperty("end_date")
val endDate: String? = null,
@field:JsonProperty("question_count")
val questionCount: Int? = null,
@field:JsonProperty("kind")
val kind: Int? = null,
@field:JsonProperty("id")
val id: Int? = null,
@field:JsonProperty("title")
val title: String? = null,
@field:JsonProperty("required_questions_count")
val requiredQuestionsCount: Int? = null,
@field:JsonProperty("status")
val status: Int? = null,
@field:JsonProperty("start_date")
val startDate: String? = null
) : BaseRecyclableObject, Serializable {
val resources: Resources = Resources.getSystem()
override val objTitle: String = title ?: resources.getString(R.string.UNKNOWN_STORE_NAME)
override val objSubtitle: String = endDate?.let { resources.getString(R.string.AVAILABLE_UNTIL, DateHandler.formatReadableYearly(it)) }
?: resources.getString(R.string.NO_END_DATE)
}
当我运行应用程序时,我收到以下错误消息
> com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot
> construct instance of`com.workshop.collect.networking.responsemodels.AvailablePollResponseModel`,
> problem: String resource ID #0x7f0d0009 at [Source:
> (String)"[{"id":880,"start_date":"2018-05-14T10:52:02.393194Z","end_date":null,"user":{"first_name":"Joel","last_name":"Brostrom","full_name":"Joel
> Brostrom","pk":3,"id":3},"module_object":[],"collected_polls":[],"available_polls":[{"id":33,"title":"Run
> for
> life","kind":2,"status":0,"start_date":"2018-04-07T22:00:00Z","end_date":"2018-06-11T22:00:00Z","question_count":4,"required_questions_count":4},{"id":34,"title":"Store
> layout
> report","kind":0,"status":0,"start_date":"2018-04-07T22:00:00Z","end_date":"[truncated
> 278 chars]; line: 1, column: 393] (through reference chain:
> java.util.ArrayList[0]->com.workshop.collect.networking.responsemodels.CheckInResponseModel["available_polls"]->java.util.ArrayList[0])
如果我无法将它们序列化,我如何本地化我的字符串?
答案 0 :(得分:0)
只需使用工具Parceable,之后定义你的String:
@SerializedName("location_name")
@Expose
private String locationName;
@SerializedName("latitude")
@Expose
private Double latitude;
@SerializedName("city")
@Expose
private String city;
@SerializedName("longitude")
@Expose
private Double longitude;
@SerializedName("state")
@Expose
private String state;