C# xml serialization remove jagged array element name

前端 未结 3 901
梦谈多话
梦谈多话 2021-01-15 02:10

I have the below classes:

public class MainRequest
{
    private Request _dataField;

    [XmlElementAttribute(\"Parameters\")]
    public Request Parameters         


        
3条回答
  •  走了就别回头了
    2021-01-15 02:56

    Through experimentation, you'll have to rename Batch to BatchEntry (apparently you cannot combine XmlElement and XmlArrayItem) and then you can you the XmlArrayItem attribute with a name of "ParameterEntry".

    This will work:

    /* No idea why this a 2-d array... It doesn't match your XML */
    [XmlArrayItem("ParameterEntry")]
    public Field[] BatchEntry    //was Batch
    

提交回复
热议问题