WebClient -下载json字符串打破json的一些格式
本文关键字:json 格式 -下载 字符串 WebClient | 更新日期: 2023-09-27 18:13:34
我有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
我正在使用web客户端下载
var json= client.DownloadString(uri);
结果和预期的差不多但它改变了一些字符串格式比如如果response中的属性值是一些,比如使用特殊字符
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.",
它把它改成了like
eventDescription: "TUM is Canada’s first and only social food market designed to"
我想要相同的响应。有什么建议吗?
您必须在调用DownloadString()
之前设置文本编码。
client.Encoding = Encoding.UTF8;
要确定使用哪种编码,请检查服务的Content-Type
响应头。
- type: application/json; charset = utf - 8