简体   繁体   中英

way to dynamicly create object from JSON format in c# dotnet core

How can I use JSON to create dynamic object in dotnet core? It used to work in old ASP.NET but in dotnet core it's not. I use the following code:

var json= "{\"itemName\":\"itemValue\"}";
var obj= JsonConvert.DeserializeObject(json);

I already using Newtonsoft.Json;

If I create a type it works

obj = JsonConvert.DeserializeObject<someType>(json);

I tried as suggested still doesn't work:

attached picture

JsonConvert.DeserializeObject<dynamic>(json)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM