I have json feed that can be seen here
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
And I am downloading it using web client
var json= client.DownloadString(uri);
The resultant is pretty much as expected but it change some string format like if the property in response has value some like which uses special character
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.",
It changes it to like
eventDescription: "TUM is Canada’s first and only social food market designed to"
I want the same as in response. Any suggestion please?
Looking at the sample JSON, we can figure out there are employee objects having department objects nested within. Mono is a reactive publisher, that can emit 0 zero or 1 elements. Thus, in order to retrieve a single JSON resource with WebClient, we should use Mono publisher. We will use WebClient to read a JSON object and parse it into POJO.
The response of the service endpoint that returns an array of JSON objects, will look like this. We need a minimal setup for this application. First, is to add required maven/gradle dependency and the other is to create model classes to parse the JSON data into. In order to use the WebClient, we need to add a dependency on Spring WebFlux.
Spring's WebClient can easily deserialize the JSON into a Reader.class when the type information is available at runtime. With generics, however, type erasure occurs if we try to use List<Reader>.class.
DownloadString(String) Downloads the requested resource as a String. The resource to download is specified as a Stringcontaining the URI. public: System::String ^ DownloadString(System::String ^ address); public string DownloadString (string address); member this.DownloadString : string -> string
You have to set the text encoding before calling DownloadString()
.
client.Encoding = Encoding.UTF8;
To figure out which encoding to use, inspect the service's Content-Type
response header.
Content-Type:application/json;charset=UTF-8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With