1

I'm doing a webrequest where I get the result in a Json. Now in the Json there are strings like:

"displayName": "Simon#27756"

Now i want to get the "value" which is in this case: Simon#27756 This is how i get the Json:

var response = client.GetAsync("webrequest link").Result;
var content = response.Content.ReadAsStringAsync().Result;
dynamic item = JsonConvert.DeserializeObject(content);

Thanks for your answers! Have a good day!

GibEinenNamenEin
  • 91
  • 1
  • 1
  • 7
  • `"displayName": "Simon#27756"` is nto valid JSON by itself. if this part of a JSON object? ie `{ "displayName": "Simon#27756" }`? – Nkosi Nov 24 '18 at 23:16
  • The whole Json starts with the {, "displayName": "Simon#27756" was just one line of the Json. – GibEinenNamenEin Nov 24 '18 at 23:20

1 Answers1

1

Assuming that the code you provided all works with your input, all you should have to do is:

var displayName = item.displayName;
Nathan Werry
  • 876
  • 7
  • 18
  • Thats not working. – GibEinenNamenEin Nov 24 '18 at 23:13
  • You might have to provide more details, because the code below works in .net 4.7 with all versions of C# that I have installed: `dynamic x = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(new { displayName = "Simon#27756" })); Console.WriteLine(x.displayName);` – Nathan Werry Nov 24 '18 at 23:38