我有一个类实现了一个我想序列化的trait:
package com.company.project.model.v2
import com.company.project.traits.v2.TOpeningTimes
class Gasstation extends Poi implements TOpeningTimes {
String brand
double diesel
double e5
double e10
}
特征类是:
package com.company.project.traits.v2
import com.company.project.model.OpeningTime
trait TOpeningTimes {
List<OpeningTime> openingTimes
boolean isOpen
}
我使用gjson为redis序列化对象。我添加了一个适配器来序列化LTS中的几何图形,所有工作都很好,但由于我使用traits,gjson序列化了如下内容:
{
"brand":"AVIA Xpress",
"diesel":1.709, "e5":1.789,
"e10":1.729,
"com_company_project_traits_v2_TOpeningTimes__isOpen":true,
"point": {
"type":"Point",
"coordinates":[8.2379,48.9507],
"crs": {
"type":"name",
"properties":{
"name":"EPSG:4326"}
}
},
"type":"GASSTATION",
"address": {
"city":"Berlin",
"houseNumber":"1",
"street":"Flixstreet"
}
}
有没有人知道如何让gson处理traits?thx
我尝试序列化goovy traits,并期望它像序列化类一样工作,但它没有
1条答案
按热度按时间r6l8ljro1#
使用gson注解工作!