我有以下课程正在转换为Json格式:
@RealmClass
open class ContainerContentExchange(currentDeviceVolume: Double? = null) : RealmObject() {
@SerializedName("Completed")
var completed: Date? = null
@SerializedName("WeightDifference")
var weightDifference: Double? = null
get() = field.getRoundedValue(3)
@SerializedName("WeightStartBrut")
var weightStart: Double? = null
get() = field.getRoundedValue(3)
set(value) {
field = value
if (completed == null) {
weightDifference = weightStop?.subtract(field ?: 0.0)
}
}
@SerializedName("WeightStopBrut")
var weightStop: Double? = null
get() = field.getRoundedValue(3)
set(value) {
field = value
if (completed == null) {
weightDifference = field?.subtract(weightStart ?: 0.0)
}
}
@SerializedName("WeightStart")
var startNettWeight: Double? = null
get() = field.getRoundedValue(3)
@SerializedName("WeightStop")
var stopNettWeight: Double? = null
get() = field.getRoundedValue(3)
}
问题是由于某些原因,weightStop
以外的所有语言都正确地更改为其序列化名称。因此,最后,我的JSON中有weightStop
和WeightStop
。
我尝试将weightStop
替换为weightStopBrut
,但它仍然没有更改为正确的序列化名称。
getRoundedValue
是扩展方法
有人知道这可能是什么问题吗?
编辑:这是要转换为JSON的代码:
Gson().toJson(exchange)
exchange
是我要序列化的ContainerContentExchange