C#C
C#3y ago
Taylor

Unable to use properties of type "object" on model objects. Json serialization is seriously invalid.

The following code is used as a model.
    public class JsonDocument
    {
        public Guid? Guid { get; set; }
        public string AppName { get; set; } = "ApiCore";
        public Object? Data { get; set; }
    }


When it is passed into the controller method:
        [HttpPost]
        [ProducesResponseType(StatusCodes.Status201Created)]
        public virtual async Task<ActionResult<Guid>> Create([FromBody] JsonDocument model)
        {
            // At this point, model.Data says something about ValueKind. What?? Why?
             ....
        }
image.png
Was this page helpful?