How to include column metadata in JSON for an empty DataTable

后端 未结 2 1796
滥情空心
滥情空心 2020-12-10 18:51

I am looking to properly describe column metadata in JSON which is later parsed by Newtonsoft to build a C# DataTable. In this way, I\'m hoping to solve a probl

2条回答
  •  盖世英雄少女心
    2020-12-10 19:37

    You can add a schema to your json: http://json-schema.org/example1.html

    What does your api method signature look like? If you are passing in a json string to be deserialized into an object you would already have the column info on the object itself. I would suggest changing your api method signature to something like:

    [HttpPost, Route("packages")]
    public IHttpActionResult Packages(IEnumerable packages)
    

    You could then use that list for your data tables or just enumerate the list as it is.

提交回复
热议问题