Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a json string from RestSharp response.

The json string looks like this:
Quote:
{"Name1":"sample1","Name2":"sample2","Name3":"Sample3"}


I was trying to deserialize it with the following code:
string data = response.Content;
Dictionary<string, object> values = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);


Now how do I call and get individual key that is contained the the deserialized Dictionary?

What I have tried:

TradeNotes.Text = values.[0]["Name1"];
Posted
Updated 4-Apr-17 5:20am

try
TradeNotes.Text = Convert.ToString(values["Name1"]); // sample1

it should be like dictionaryObject["Key"] to get the Value
 
Share this answer
 
v2
Is this what you want?

C#
var keys = values.Keys.ToArray();
 
Share this answer
 
Comments
OriginalGriff 9-Feb-22 4:11am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 5 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900