我正在使用 Jackson 将 JSON 写入文本文件,JSON 表示从抽象类继承的 2 个类,但无论是否使用两个类或一个/或一个类,都会发生错误。JSON 似乎编写正确,但在阅读时,我收到以下错误:
Missing type id when trying to resolve subtype of [simple type, class model.BaseContact]: missing type id property 'type'
at [Source: (File); line: 52, column: 1]
json as follows:
{
"allContacts" : [ {
"type" : "personal",
"addressCity" : "Hamilton",
"addressNum" : "199",
"addressPOBox" : null,
"addressPostCode" : null,
"addressStreet" : "River Rd",
"addressSuburb" : null,
"email" : null,
"latitude" : null,
"longitude" : null,
"name" : "silly simon",
"notes" : null,
"phoneNumber" : "09754321",
"photoBytes" : null,
"photoURL" : null
}, {
"type" : "personal",
"addressCity" : "Auckland",
"addressNum" : "482",
"addressPOBox" : null,
"addressPostCode" : null,
"addressStreet" : "Smith Rd",
"addressSuburb" : null,
"email" : null,
"latitude" : null,
"longitude" : null,
"name" : "paul smith",
"notes" : null,
"phoneNumber" : "0544555",
"photoBytes" : null,
"photoURL" : null
}, {
"type" : "personal",
"addressCity" : "Appleby",
"addressNum" : "123",
"addressPOBox" : null,
"addressPostCode" : null,
"addressStreet" : "Apple rd",
"addressSuburb" : null,
"email" : null,
"latitude" : null,
"name" : "Steve Jobbs",
"notes" : null,
"phoneNumber" : "08004343",
"photoBytes" : null,
"photoURL" : null
} ],
"size" : 3
}
错误消息指的是第 52 行第 1 列,假设调试器从第 1 行开始,该行将是最后一个大括号之后的行。
收到一只叮咚
相关分类