I have a C# app, that has an object, that looks like this:
public class MyObject
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; }
...
}
I then get a list of objects like this:
var myObjects = MyObject.LoadAll();
I need to create a JSON object that looks like this:
{ "1":"James", "2":"Bill", "3":"Andrew" }
1, 2, and 3 are the Id values of the list of MyObject entities. "James", "Bill", and "Andrew" are the values of the "Name" property from each object. How do I create a JSON object in this manner using just the two properties?
Thank you!