How can I convert the JSON into a multidimensional array?

0 like 0 dislike
114 views
There is such JSON:
{ "cities": { "CountryName": [{ "name": "Sentra" }, { "name": "Sentra" }, { "name": "Sentra" } ], "CountryName2": [{ "name": "Sentra" }, { "name": "Sentra" } ] } }

How to convert a multidimensional array of type string[,] cities = new string[,] { };?
Tried using this websitebut it is something that gives:
public class CountryName { public string name { get; set; } } public class CountryName2 { public string name { get; set; } } public class Cities { public List CountryName { get; set; } public List CountryName2 { get; set; } } public class RootObject { public Cities cities { get; set; } }

That is, every country and city pre-register in the class. Maybe with JSON, something wrong?
by | 114 views

2 Answers

0 like 0 dislike
how to convert?? handles..
all right you Sait issues..
two countries in each list of cities....

you do not have the array inside cities

you may want
{ "cities": [{ "CountryName": [{ "name": "Sentra" }, { "name": "Sentra" }, { "name": "Sentra" } ], "CountryName2": [{ "name": "Sentra" }, { "name": "Sentra" } ] } ] }


and you will generate a list of lists.
can you justify why do you need a multidimensional array..and than a list of lists does not suit you??
by
0 like 0 dislike
There is a simple, lentyayskogo path: allocated (preferably large) JSON and in Studio edit->paste special -> paste JSON as Classes

Then look at classes, slightly rythem data types, mark DataContract and members and have happiness in the form of successful serializable from DataContractJsonSerializer to any fancy necrobones library/framework (e.g. Json.NET)
by

Related questions

0 like 0 dislike
2 answers
asked May 20, 2019 by EvgMul
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Jun 4, 2019 by itgood
110,608 questions
257,187 answers
0 comments
40,796 users