【问题标题】:WebClient - Download json as string break some format of jsonWebClient - 以字符串形式下载 json 格式的 json
【发布时间】:2014-07-18 12:46:07
【问题描述】:

我有可以在这里看到的 json 提要

http://www.ticketfly.com/api/events/upcoming.json?orgId=1&pageNum=1&fieldGroup=light&fields=dateCreated,featured,published,publishDate,image,onSaleDate,offSaleDate,promoterName,sponsorName,sponsorImage,additionalInfo,showTypeCode,showType,externalTicketingUrls,facebookEventId,isMobileFriendly,isMobileFriendlyBoolean,headliners.id,headliners.name,headliners.startTime,headliners.eventDescription,headliners.urlOfficialWebsite,headliners.urlMySpace,headliners.urlFacebook,headliners.urlTwitter,headliners.urlAudio,headliners.urlPurchaseMusic,headliners.embedAudio,headliners.embedVideo,headliners.image.original,headliners.image.xlarge,headliners.image.large,headliners.image.medium,headliners.image.small,headliners.image.xlarge1,headliners.image.large1,headliners.image.medium1,headliners.image.small1,headliners.image.square,headliners.image.squareSmall,supports.id,supports.name,supports.startTime,supports.eventDescription,supports.urlOfficialWebsite,supports.urlMySpace,supports.urlFacebook,supports.urlTwitter,supports.urlAudio,supports.urlPurchaseMusic,supports.embedAudio,supports.embedVideo,supports.image.original,supports.image.xlarge,supports.image.large,supports.image.medium,supports.image.small,supports.image.xlarge1,supports.image.large1,supports.image.medium1,supports.image.small1,supports.image.square,supports.image.squareSmall,org.id,org.name,org.timeZone,org.promoter,venue.timeZone,venue.address1,venue.address2,venue.city,venue.stateProvince,venue.postalCode,venue.metroCode,venue.country,venue.url,venue.blurb,venue.urlFacebook,venue.urlTwitter,venue.lat,venue.lng,venue.image,urlEventDetailsUrl

我正在使用网络客户端下载它

var json= client.DownloadString(uri);

结果和预期的差不多,但是它改变了一些字符串格式,比如响应的属性有一些使用特殊字符的值

eventDescription: "TUM is Canada’s first and only social food market designed to give budding food entrepreneurs, chefs and home cooks a platform to test new food ideas to an eager market. Since September 2011, each TUM event has featured new cooks & chefs wanting to exhibit their food plus various local craft beer, wine & cocktails.",

它改变它喜欢

 eventDescription: "TUM is Canada’s first and only social food market designed to"

我想要同样的回应。请问有什么建议吗?

【问题讨论】:

  • 文本编码好像不对...

标签: c# json webclient


【解决方案1】:

你必须在调用DownloadString()之前设置文本编码。

client.Encoding = Encoding.UTF8;

要确定使用哪种编码,请检查服务的 Content-Type 响应标头。

Content-Type:application/json;charset=UTF-8

【讨论】:

  • 太棒了。不错的收获,会在某个时候接受答案
猜你喜欢
  • 1970-01-01
  • 2018-01-10
  • 2014-10-03
  • 2011-10-25
  • 1970-01-01
  • 1970-01-01
  • 2021-01-27
  • 2021-09-25
  • 2015-04-02
相关资源
最近更新 更多