I need to create a JToken
dynamically. The Brand p["properties"]["brand"][0]
property must be constructed via string fields from some object. I want to be able to put this in a textbox: ["properties"]["dog"][0]
and let that be the brand selection.
Thus far I have the selection hardcoded like this:
JObject o = JObject.Parse(j);
JArray a = (JArray)o["products"];
var products = a.Select(p => new Product
{
Brand = (string)p["properties"]["brand"][0]
}
I however need something like this:
JObject o = JObject.Parse(j);
JArray a = (JArray)o["products"];
string BrandString = "['descriptions']['brand'][0]";
var products = a.Select(p => new Product
{
Brand = (string)p[BrandString]
}
Is this possible somehow?