2
Hello, I’m having trouble deserializar a Json, I’m not getting the right data.
There is the Main Class that would receive the data list
public class PermissaoDossie
{
[JsonProperty(PropertyName = "data")]
public string data { get; set; }
[JsonProperty(PropertyName = "listPermissoes")]
public string listPermissoes { get; set; }
[JsonProperty(PropertyName = "dadosPermissao")]
public string dadosPermissao { get; set; }
[JsonProperty(PropertyName = "name")]
public string name { get; set; }
[JsonProperty(PropertyName = "value")]
public string value { get; set; }
}
And the List Class
public class RootObject
{
public List<PermissaoDossie> dossie { get; set; }
}
Here is the Json and the process
String JsonString = {"data":{"listPermissoes":[{"dadosPermissao":[{"name":"usuario","value":"ADMINISTRADOR"},{"name":"codigo_usuario","value":"1"},
{"name":"unidade","value":"Unidade qualquer"},{"name":"codigo_unidade","value":"001"},
{"name":"nivel","value":"R"}]},
{"dadosPermissao":[{"name":"usuario","value":"Usuario qualquer"},{"name":"codigo_usuario","value":"23945"},{"name":"unidade","value":"Administração"},{"name":"codigo_unidade","value":"1302"},
{"name":"nivel","value":"M"}]}]},"service":{"name":"ConsultaPermissao"},"message":{"type":"success","value":""}}
//////// Here makes the Deserialization wrong
var result = JsonConvert.DeserializeObject<IDictionary<string, RootObject>>(JsonString);
This is the Output, but I want the value within the name and value
is not a list? you have to make a loop to get the values
– Marco Souza
So, but I need first managed to get Jsonstring into a list structure with name and value to run a Loop
– Renan Silveira