Newton
is your friend,
static void Main(string[] args)
{
string test = "{'en':'Some Value', 'fr':'Value is here'}"; // this is your json input
ObjectTest converted = JsonConvert.DeserializeObject<ObjectTest>(test); // deserialize json input to your custom object
}
Here is the example object;
public class ObjectTest {
public string en { get; set; }
public string fr { get; set; }
}
Result;
Or you can take Keys
and Values
from JObject
like this,
static void Main(string[] args)
{
string test = "{'en':'Some Value', 'fr':'Value is here'}"; // this is your json input
JObject converted = JsonConvert.DeserializeObject<JObject>(test);
if (converted != null)
{
Dictionary<string, string> keyValueMap = new Dictionary<string, string>();
foreach (KeyValuePair<string, JToken> keyValuePair in converted)
{
keyValueMap.Add(keyValuePair.Key, keyValuePair.Value.ToString());
}
}
}
Result;
