我正在使用wcf服务,我必须访问wcf服务方法并在浏览器中显示返回的json数据。 目前我尝试使用字符串方法,因此json数据显示为json字符串格式,这是不正确的。 我已经完成了这个link并尝试了我的代码,但没有得到任何代码 由于完整数据的数据在一个列表中。
以下是IService代码接口:
using namespace std;

Service1.svc代码:
[ServiceContract]
public interface IService1
{
[OperationContract]
List<SuccessStoryApp> GetSuccessStoryJson();
[OperationContract]
[WebInvoke(Method = "GET",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/GetBlogList/")]
string GetBlogList();
}
&#13;
public string GetBlogList()
{
log.Info("GetBlostList method entered");
List<SuccessStoryApp> storyList = new List<SuccessStoryApp>();
string jsonString = string.Empty;
var jsonData = GetSuccessStoryJson();
storyList = jsonData.Select(x => new SuccessStoryApp
{
Author = x.Author,
AuthorSlug = x.AuthorSlug,
Available = x.Available,
Category = x.Category,
CountryCode = x.CountryCode,
Description = x.Description,
LanguageCode = x.LanguageCode,
PublishedDate = x.PublishedDate,
Quote = x.Quote,
ShortDescription = x.ShortDescription,
StoryImageAlt = x.StoryImageAlt,
StoryImageTitle = x.StoryImageTitle,
StoryImageURL = x.StoryImageURL,
Tags = x.Tags,
Text = x.Tags,
Title = x.Title,
TitleImageURL = x.TitleImageURL,
Type = x.Type
}).ToList();
if (storyList.Count > 0)
{
var json = JsonConvert.SerializeObject(storyList);
jsonString = json;
}
else
{
jsonString = "Some error occurred";
}
return jsonString;
}
&#13;