This is my JSON
{
"Id":535325,
"Etiqueta":"RENOV_CORPORATIVOS_MAI23",
"Urgente":false,
"DataCriacao":"2023-05-01T00:00:00",
"Entidade":{
"Id":2551,
"RazaoSocial":"IBR",
"NomeInterno":"IBR",
"Cnpj":"23.000.000\/0001-06",
"Vinculo":"Fornecedor"
},
"Empresa":{
"Id":20193,
"RazaoSocial":"AND",
"NomeFantasia":"SCH",
"Cnpj":"08.000.000\/0001-42",
"CapitalSocial":300.00,
"Municipio":"SAO PAULO",
"UF":"SP"
},
"ItensFila":[
{
"key":"FGTS",
"value":{
"Id":10133534,
"IdDocumento":3,
"Positiva":false,
"Nomenclatura":"FGTS"
}
},
{
"key":"MPF",
"value":{
"Id":10133566,
"IdDocumento":502,
"Positiva":false,
"Nomenclatura":"MPF"
}
},
{
"key":"CADIN_SP_SaoPaulo",
"value":{
"Id":10133552,
"IdDocumento":391,
"Positiva":true,
"Nomenclatura":"CADIN_SP_SaoPaulo"
}
},
{
"key":"RFB",
"value":{
"Id":10133533,
"IdDocumento":1,
"Positiva":true,
"Nomenclatura":"RFB",
"Detalhamento":{
"Id":19464811,
"OcorrenciaCurta":"RFB\/PGFN",
"p0":"RFB\/PGFN"
}
}
}
]
}
I need to deserialize it to a complex object, as follows:
public class Fila
{
public int Id { get; set; }
public string Etiqueta { get; set; }
public bool Urgente { get; set; }
public int IdSolicitacao { get; set; }
public DateTime DataCriacao { get; set; }
public Entidade Entidade { get; set; }
public Empresa Empresa { get; set; }
public Dictionary<string, ItemFila> ItensFila { get; set; }
public string Risco { get; set; }
}
public class ItemFila
{
public string Nomenclatura { get; set; }
public int Id { get; set; }
public int IdDocumento { get; set; }
public bool Positiva { get; set; }
public Detalhamento? Detalhamento { get; set; }
}
public class Detalhamento
{
public int Id { get; set; }
public string OcorrenciaCurta { get; set; }
public string OcorrenciaLonga { get; set; }
public string p0 { get; set; }
}
note the Dictionary<string, ItemFila> in Fila Class.
I could not parse json to fill this dictionary. I'm receiving an error saying:
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.String,Ibr.Api.Risco.Models.ItemFila]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
how can I deserialize it?