我想要将一个具有潜在可变数量键的JSON对象序列化,这些键代表手机设备ID(由于Android和iPhone之间的差异)。例如,JSON对象可能如下所示(对于Android):
"deviceids":{
"openudid":"",
"androidid":"dcbfXXXXXc2d5f",
"imei":"3533XXXXX941712"
}
相比之下,iPhone的外观如下所示:
"deviceids":
{
"openudid":"37368a5361XXXXXXXXXXdaedc186b4acf4cd4",
"ifv":"BD87ECBF-XXXXXXXXXX-DDF46E18129A",
"mac":"XXXXXXXXXX",
"odin":"2f5672cXXXXXXXXXX2022a5349939a2d7b952",
"ifa":"82F7B2AXXXXXXXXXX5-A2DADA99D05B"
}
在Avro中,我认为这样的模式可以解释这些差异:
{
"name":"deviceids",
"type":"record",
"fields":[
{
"type":"array",
"items":{
"type":"map",
"values":"string"
}
}
]
}
这是一个有效的Avro模式吗?