我有以下工会:
{
"name" : "price",
"type" : [ "null", {
"type" : "array",
"items" : {
"type" : "record",
"name" : "PriceType",
"fields" : [ {
"name" : "text_value",
"type" : [ "null", "double" ],
"source" : "element text_value"
}, {
"name" : "currency",
"type" : [ "null", "string" ],
"default" : null,
"source" : "attribute currency"
} ]
}
} ],
"default" : null,
"source" : "element price"
}
从此联合中,使用以下代码获取价格字段的架构:
Schema new_schema=schema.getField("price").schema();
现在,我想获取联盟的架构:
{
"type" : "array",
"items" : {
"type" : "record",
"name" : "PriceType",
"fields" : [ {
"name" : "text_value",
"type" : [ "null", "double" ],
"source" : "element text_value"
}, {
"name" : "currency",
"type" : [ "null", "string" ],
"default" : null,
"source" : "attribute currency"
}
我该怎么做?我如何在记录中插入联合?