I have a C# Object that I need its attribute values into its own json object. I'm struggling with how to do this dynamically. I have attributes in my C# class that have values and I need to make those attribute values the Key/Value pair in the json respectively.
public class TransHelper
{
public string Key { get; set; }
public string Translation { get; set; }
}
TransHelper j = new TransHelper { Key = "MyKeyValue",
Translation = "MyTranslationValue" };
// Need to be json like this
// json { MyKeyValue: MyTranslationValue }
How do I make the attribute values get inserted into a new object where j.Key value is the new Key and j.Translation is the new value? I can use newtonsoft or any json libraries out there, I am sure there is something simple I am missing here.