desectuate Json object

Asked

Viewed 91 times

-4

Guys I’m not getting to realize 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"
        },
  • { "Resource": "TRANSACTION", "transaction": { "0": { "id": "1409", "datetime_operation": "30/06/2018 08:06:50", "logico_terminal": "524889882", "ref_EC": "RODRIGO", "valor_operated": "0,00", "parcels": ", "typo_operation": "", "parsed_type": "", "parsed_status": "", "card_holder_name": "", "cardmask": "******", "flag": "", "antecipaca_auto": "No", "nsu": "4145-0-0" },

  • Post a valid json. what you posted this unusual.

  • Your JSON appears to be invalid. Please use this site to check https://jsonformatter.curiousconcept.com/

  • Flagged as duplicate. Friend, kindly post the code as far as you have done (part of the deserialization) and what error you receive.

1 answer

0

If you analyze JSON you will see that it is not an array. I used the site json2csharp to build the class from the 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, not the content of transactionis not an array but a set of unknown type properties (0,1,2)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.