简体   繁体   中英

getting string like when I return a list

The result I am getting

falsef005fdc9-7781-4c75-9f54-0a05a7fc6e71bc3d0990-2f44-491f-a25a-3771772d6a61false2017-10-10T08:43:16.0831010019false

I am getting like the format as below when I use the postman.

  1. Question: How do I remove [] ? I tried to remove ToList() but it didn't work.
  2. Question: Why I am getting a string like result instead of json?

在此处输入图像描述

controller method

public IEnumerable<ClientModel> GetClients()
{
    var clients = ClientHelper.GetAllClients();
    var result = (from c in clients
                  select c).ToList(); 

    return Mapper.Map<IEnumerable<ClientModel>>(result);

}

Use this namespace

using System.Web.Script.Serialization;

and

var json_result = new JavaScriptSerializer().Serialize(result );

You must get json data in json_result

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