Estoy usando una biblioteca Json.NET. ¿Cuál es la forma más conveniente de serializar/deserializar matrices en JSON a través de C#? Por ejemplo, yo estoy tratando de deserializar el siguiente texto (al leer el archivo):Json.NET: matrices de serialización/deserialización
{
"Name": "Christina",
"Gender": "female",
"Favorite_numbers": [11, 25 ,23]
}
estoy leyendo el texto anterior de un archivo a una variable:
JObject o = JObject.Parse(File.ReadAllText("input.txt"))
Y luego, cuando me estoy tratando de extraer una matriz [11, 24, 23]
con el
int[] num = (int[]) o["Favorite_numbers"]
recibo un error.
¿Qué estoy haciendo mal? ¿Cómo leo correctamente una matriz? ¿Cómo leo correctamente las matrices de 2 dim del siguiente tipo [[1, 2, 3], [4, 5, 6]]
?
¿Cuál es el error ? –