Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
API & Integration · Chapter 02 / 16

API & Integration

Data formats & serialization

APIs exchange bytes, but those bytes usually represent structured data. The format tells the client and server how to interpret that data.

JSON

JSON is a text data-interchange format. It is not the same thing as an object from Python, JavaScript, C# or another programming language.

JSON can contain six kinds of values:

JSON valueExample
string"Alice"
number42, 3.14
booleantrue, false
nullnull
object{"name":"Alice"}
array[1,2,3]

A complete JSON document does not have to be an object. An array, string, number, boolean or null can also be the top-level value.

{
  "name": "Alice",
  "age": 35,
  "active": true,
  "skills": ["Python", "C#"],
  "address": null
}

JSON has no native date or datetime type. A value such as "2026-09-01T12:00:00Z" is still a JSON string; the API contract defines that the string represents a date and time.

JSON also does not define separate integer, float or decimal value types. It has the single JSON number type; application schemas and programming languages can apply more specific numeric rules.

XML

XML is another text format for structured data. Its structure is built from elements, attributes and text.

<user id="42">
  <name>Alice</name>
  <active>true</active>
</user>

XML is case-sensitive and elements must be correctly nested and closed. Unlike JSON, XML does not itself provide JSON-style object, array, number or boolean value categories. A schema such as XSD can define data types and structural rules.

SOAP uses XML, but SOAP, WSDL, XSD and XML namespaces are covered separately in SOAP & XML APIs.

Serialization and deserialization

Serialization converts an application value or object into a transferable representation such as JSON or XML. Deserialization parses that representation back into values used by the application.

For example, an HTTP response may contain JSON bytes. A Python client can deserialize them into a dict; a C# client can deserialize the same JSON into a class instance. The JSON itself is neither a Python dictionary nor a C# object.

Media types

HTTP uses Content-Type to describe the format of message content and Accept to tell the server which response formats the client can process.

ContentCommon media type
JSONapplication/json
XMLapplication/xml
Plain texttext/plain
HTML form fieldsapplication/x-www-form-urlencoded
Multipart form / file uploadmultipart/form-data
Arbitrary binary dataapplication/octet-stream

The HTTP details of Content-Type, Accept, request bodies and file upload remain in HTTP & REST APIs.

Missing, null and empty are different

These states can mean different things in an API contract:

{"name": null}
{"name": ""}
{}

The first explicitly sends null, the second sends an empty string, and the third omits name completely. Whether they are valid or equivalent is defined by the API contract or schema.

Source registry

3 chapter references
RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format

Primary reference for JSON syntax, values and interoperability.

IETF / RFC Editor · internet standard
Source ↗
RFC 7303 — XML Media Types

Reference for XML media types and character encoding conventions.

IETF / RFC Editor · rfc reference
Source ↗
RFC 9110 — HTTP Semantics

Primary reference for HTTP methods, status codes, headers, message semantics and content negotiation.

IETF / RFC Editor · internet standard
Source ↗