Skip to content

Deserialization

Mahmoud A. Zaid edited this page Mar 17, 2019 · 4 revisions

In this lesson, we will Understand the concept of Deserialization with RestSharp in C#

Serialization is a process of converting an object into a sequence of bytes which can be persisted to a disk or database or can be sent through streams. The reverse process of creating an object from a sequence of bytes is called deserialization.

What is Serialization?

  • Serialization is a process of converting an object into a sequence of bytes such as Json which can be persisted to a disk or database or can be sent through streams. The reverse process of creating object from sequence of bytes is called deserialization.
  • Deserialization Converting any encoding format to Objects

RestSharp includes deserializers to process XML and JSON. Upon receiving a response, RestClient chooses the correct deserializer to use based on the Content-Type returned by the server.

The built-in content types supported are:

  • application/json - JsonDeserializer
  • application/xml - XmlDeserializer
  • text/json - JsonDeserializer
  • text/xml - XmlDeserializer
  • *+json - JsonDeserializer (content types using a Structured Suffix Syntax specifying JSON)
  • *+xml - XmlDeserializer (content types using a Structured Suffix Syntax specifying XML)
  • @*@ - XmlDeserializer (all other content types not specified)

Why it is needed?

  • Serialize it to create the request body and send it as a JSON file
  • Deserialize it into an object type that makes sense for the consumer, accesses the response content and check if the returned response is correct
Clone this wiki locally