0

I want get value like array[0].FNAME

How to get in c# ?

[
  {
    "ID": 4012,
    "FNAME": "MyNAme",
    "MNAME": null,
    "LNAME": "Surname",
    "TITLE": null,
  },
  {
    ....
  }
]
Richard Deeming
  • 29,830
  • 10
  • 79
  • 151
  • 1
    Parse it into a concrete data type or into JObject/JToken (Newtonsoft) then access the array element and the property? – crashmstr Jan 27 '22 at 12:15
  • @huMptyduMpty Ugh; the problem with decade+ old canoncicals is that they might unnecessarily push a user into doing something like we did more than 10 years ago.. The first two answers on that one (if the OP is in Oldest mode) promote the decrepit JavaScriptSerializer. If you dupe-link to something like that, which has a full spread of answers some of which are less desirable in a modern context, you should perhaps consider calling the OP to a particular answer – Caius Jard Jan 27 '22 at 12:30
  • See Haldo's answer in https://stackoverflow.com/questions/7895105/deserialize-json-with-c-sharp - a good bit of advice that can be summarized as: "Take your JSON there and paste it into https://app.quicktype.io, pick a name and a namespace, and set C# as the target language, then paste the code it generates into your project. **Read the comments** of the generated code; it will tell you the one line of code you need to use to turn your json string into the c# objects". You code will literally end us as 2 lines: `var o = SomeNameYouChose.FromJson(yourJsonStringHere); var fname = o[0].Fname;` – Caius Jard Jan 27 '22 at 12:35

0 Answers0