These are my classes:
public class RequestEntity
{
public int Category { get; set; }
public List<string> Types { get; set; }
public List<Parameters> parameters { get; set; }
}
public class Parameters
{
public string Name { get; set; }
public string Type { get; set; }
public bool IsRecent { get; set; }
}
After setting value to:
List<RequestEntity> request = new List<RequestEntity>();
Now I need to create a JObject
with 2 properties.
JObject requestObject = new JObject();
JProperty property1 = new JProperty("Details", request);
JProperty property2 = new JProperty("SpanInDays", 10);
requestObject.Add(property1);
requestObject.Add(property2);
The line JProperty property1 = new JProperty("Details", request);
is giving me following error.
Could not determine JSON object type for type DAL.Entity.RequestEntity.
You must use some kind of JToken
as the value of a JProperty
(at least in the case of complex types). You can easily get one of those by using FromObject
:
JProperty property1 = new JProperty("Details", JToken.FromObject(request));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.