deserialize JSOn object

-4

I am not able to underealise this object,

public class itensjsonPai
{
    public string resource { get; set; }
    public List<transaction> transaction { get; set; }
}

public class itensjsonfilho
{


    public string id { get; set; }
    public string datetime_operacao { get; set; }
    public string logico_terminal { get; set; }
    public string ref_EC { get; set; }
    public decimal valor_operado { get; set; }
    public string parcelas { get; set; }
    public string tipo_operacao { get; set; }
    public string parsed_type { get; set; }
    public string parsed_status { get; set; }
    public string card_holder_name { get; set; }
    public string cardmask { get; set; }
    public string bandeira { get; set; }
    public string antecipacao_auto { get; set; }
    public string nsu { get; set; }
}

Object:

{
    "resource": "TRANSACTION",
    "transaction": {
        "0": {
            "id": "1409",
            "datetime_operacao": "30/06/2018 08:06:50",
            "logico_terminal": "524889882",
            "ref_EC": "RODRIGO",
            "valor_operado": "0,00",
            "parcelas": "",
            "tipo_operacao": "",
            "parsed_type": "",
            "parsed_status": "",
            "card_holder_name": "",
            "cardmask": "******",
            "bandeira": "",
            "antecipacao_auto": "Não",
            "nsu": "4145-0-0"
        },
        "1": {
            "id": "1408",
            "datetime_operacao": "30/06/2018 08:06:40",
            "logico_terminal": "524889882",
            "ref_EC": "RODRIGO",
            "valor_operado": "0,00",
            "parcelas": "",
            "tipo_operacao": "",
            "parsed_type": "",
            "parsed_status": "",
            "card_holder_name": "",
            "cardmask": "******",
            "bandeira": "",
            "antecipacao_auto": "Não",
            "nsu": "4141-0-0"
        },
        "2": {
            "id": "1407",
            "datetime_operacao": "30/06/2018 08:06:29",
            "logico_terminal": "524889882",
            "ref_EC": "RODRIGO",
            "valor_operado": "0,00",
            "parcelas": "",
            "tipo_operacao": "",
            "parsed_type": "",
            "parsed_status": "",
            "card_holder_name": "",
            "cardmask": "******",
            "bandeira": "",
            "antecipacao_auto": "Não",
            "nsu": "4131-0-0"
        },
    
asked by anonymous 20.07.2018 / 16:43

1 answer

0

If you analyze JSON you will see that it is not an array. I used json2csharp to build the class from json, and the result was:

public class __invalid_type__0
{
    public string id { get; set; }
    public string datetime_operacao { get; set; }
    public string logico_terminal { get; set; }
    public string ref_EC { get; set; }
    public string valor_operado { get; set; }
    public string parcelas { get; set; }
    public string tipo_operacao { get; set; }
    public string parsed_type { get; set; }
    public string parsed_status { get; set; }
    public string card_holder_name { get; set; }
    public string cardmask { get; set; }
    public string bandeira { get; set; }
    public string antecipacao_auto { get; set; }
    public string nsu { get; set; }
}

public class __invalid_type__1
{
    public string id { get; set; }
    public string datetime_operacao { get; set; }
    public string logico_terminal { get; set; }
    public string ref_EC { get; set; }
    public string valor_operado { get; set; }
    public string parcelas { get; set; }
    public string tipo_operacao { get; set; }
    public string parsed_type { get; set; }
    public string parsed_status { get; set; }
    public string card_holder_name { get; set; }
    public string cardmask { get; set; }
    public string bandeira { get; set; }
    public string antecipacao_auto { get; set; }
    public string nsu { get; set; }
}

public class __invalid_type__2
{
    public string id { get; set; }
    public string datetime_operacao { get; set; }
    public string logico_terminal { get; set; }
    public string ref_EC { get; set; }
    public string valor_operado { get; set; }
    public string parcelas { get; set; }
    public string tipo_operacao { get; set; }
    public string parsed_type { get; set; }
    public string parsed_status { get; set; }
    public string card_holder_name { get; set; }
    public string cardmask { get; set; }
    public string bandeira { get; set; }
    public string antecipacao_auto { get; set; }
    public string nsu { get; set; }
}

public class Transaction
{
    public __invalid_type__0 __invalid_name__0 { get; set; }
    public __invalid_type__1 __invalid_name__1 { get; set; }
    public __invalid_type__2 __invalid_name__2 { get; set; }
}

public class RootObject
{
    public string resource { get; set; }
    public Transaction transaction { get; set; }
}

That is, the content of transaction is not an array but a set of properties of unknown type (0,1,2)

    
20.07.2018 / 16:58