I am reading a resource file in C# and converted it to the JSON string format. Now I want to convert that JSON string's value as keys.
Example,
[
{
"key": "CreateAccount",
"text": "Create Account"
},
{
"key": "EmailAddress",
"text": "Email Address"
}
]
So I just want to make the above json string into "Key:text" as like below,
[
{
"CreateAccount": "Create Account"
},
{
"EmailAddress": "Email Address"
}
]
My C#,
var obj = new
{
Lang=XElement.Parse(_FileDataAsText)
.Elements("data")
.Select(el => new
{
key= el.Attribute("name").Value,
text = el.Element("value").Value
}.ToList()
};
string json = JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented);