c# How to retrieve Json data into an array
Have a look at this: Parsing JSON using Json.net
Here is some Json.NET specific documentation for serializing and deserializing arrays: Serializing Collections with Json.NET
2xj
Updated on August 02, 2020Comments
-
2xj almost 4 years
I have found different libraries that can parse Json data, but i did not find any documentation on how to get the data into an C# array or list.
I got this Json data:
{"001":{"Name":"John", "Phone":["Mob - 98837374","Mob - 98363627"]}, "002":{"Name":"Tom", "Phone":["Mob - 49858857"]}}
Anybody got a clue? :)
Edit:
Useful details posted by OP as comments re-posted as question edit by AnthonyWJones
My code using JSON.NET:
StringBuilder sb = new StringBuilder(); List<string> entities = (List<string>)JsonConvert.DeserializeObject(responseFromServer, typeof(List<string>)); foreach (string items in entities) { sb.Append(items); }
But i always get an error when i debug:
Warning 1 Reference to type 'System.DateTimeOffset' claims it is defined in 'c:\Program >> Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\mscorlib.dll', but it could not >> be found c:\Div\Json dot net\Bin\Newtonsoft.Json.dll"
-
2xj over 14 yearsMy code using JSON.NET: StringBuilder sb = new StringBuilder(); List<string> entities = (List<string>)JsonConvert.DeserializeObject(responseFromServer, typeof(List<string>)); foreach (string items in entities) { sb.Append(items); } But i always get an error when i debug: "Warning 1 Reference to type 'System.DateTimeOffset' claims it is defined in 'c:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\mscorlib.dll', but it could not be found c:\Div\Json dot net\Bin\Newtonsoft.Json.dll"
-
John Farrell over 14 yearsBetter to comment on the answer rather than to use an answer spot as a discussion board.