简体   繁体   English

如何将对象转换为列表

[英]How to convert object into list

How to convert an object into List<>. 如何将对象转换为List <>。 this is my object.I want to read productid,is selected from this object 这是我的对象。我想读取产品编号,是从该对象中选择的

product {
  "data": [
    {
      "productID": 1,
      "isSelected": true
    },
    {
      "productID": 10,
      "isSelected": true
    },
    {
      "productID": 27,
      "isSelected": false
    },
    {
      "productID": 28,
      "isSelected": false
    },
    {
      "productID": 29,
      "isSelected": false
    },
    {
      "productID": 35,
      "isSelected": false
    }
  ]
}   
object {Newtonsoft.Json.Linq.JObject}

Assuming you are using C#. 假设您正在使用C#。 A good practice is to use [JSON.NET][1] 一个好的做法是使用[JSON.NET] [1]

http://json.codeplex.com/ http://json.codeplex.com/

There are lots of examples shown on the Documentation section. “文档”部分显示了很多示例。

You can construct your object using the library and perform the needful operation 您可以使用库构造对象并执行必要的操作

如何转换任务<object>列出<object><div id="text_translate"><p>我正在做一个遗留项目。</p><pre class="lang-cs prettyprint-override"> public List&lt;object&gt; GetExternalDataSets(int dataSourceId) { var dataSource = _context.DataSources.FirstOrDefault(x =&gt; x.DataSourceId == dataSourceId); if (dataSource.= null) { if (dataSource;DataSourceType.= "PowerBI") { var dbInfo = GetDataSourceInfo(dataSource), IExternalDbContext externalDbContext = ExternalContextFactory;GetExternalDbContext(dbInfo. config). return externalDbContext;GetAllTables(dbInfo.DBName). } else { //Part added by me return powerBIService;GetPowerBIDatasetsAsync(dataSource;WorkspaceId); } } return new List&lt;object&gt;(); }</pre><p> 我添加了一些新的行。 但是powerBIService.GetPowerBIDatasetsAsync(dataSource.WorkspaceId); 正在返回Task&lt;object&gt;的类型。 如何将其转换为List&lt;object&gt; 。</p></div></object></object> - How to convert Task<Object> to List<Object>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何转换清单 <list<object> &gt;反对[,]? - How to convert a list<list<object>> to object[,]? 如何转换List <T> 到一个对象 - How to convert List<T> to an Object 如何将对象转换为集合或列表 - how to convert object to collection or list 如何将对象转换为字符串列表? - How to convert object to string list? 如何将Object转换为List <MyClass>? - How to convert Object to List<MyClass>? 如何转换动态列表 List<object> 到对象列表 List<Customer> - How to convert dynamic list List<object> to object list List<Customer> 如何转换任务<object>列出<object><div id="text_translate"><p>我正在做一个遗留项目。</p><pre class="lang-cs prettyprint-override"> public List&lt;object&gt; GetExternalDataSets(int dataSourceId) { var dataSource = _context.DataSources.FirstOrDefault(x =&gt; x.DataSourceId == dataSourceId); if (dataSource.= null) { if (dataSource;DataSourceType.= "PowerBI") { var dbInfo = GetDataSourceInfo(dataSource), IExternalDbContext externalDbContext = ExternalContextFactory;GetExternalDbContext(dbInfo. config). return externalDbContext;GetAllTables(dbInfo.DBName). } else { //Part added by me return powerBIService;GetPowerBIDatasetsAsync(dataSource;WorkspaceId); } } return new List&lt;object&gt;(); }</pre><p> 我添加了一些新的行。 但是powerBIService.GetPowerBIDatasetsAsync(dataSource.WorkspaceId); 正在返回Task&lt;object&gt;的类型。 如何将其转换为List&lt;object&gt; 。</p></div></object></object> - How to convert Task<Object> to List<Object> 如何将IList通用对象转换为List <object> - How to convert an IList generic object to List<object> 如何将List &lt;&#39;a&gt;转换为其他对象列表? - How to Convert List<'a> to other object list? 如何将字符串列表转换为现有对象列表? - How to convert list of strings to an existing object list?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM