Advanced level · Module 4 of 6 · 20 guided hours
HTTP Clients and JSON in Java
Call web APIs with Java's HttpClient, convert between JSON and Java objects with Jackson, and handle slow or failing networks.
Learning objectives
- Send HTTP requests and interpret responses and status codes
- Convert JSON to and from Java records with Jackson
- Handle timeouts, errors and unreliable connectivity gracefully
Topics
- HTTP methods, headers and status codes
- java.net.http.HttpClient
- JSON structure
- Jackson ObjectMapper
- timeouts and retries
- caching for offline use
Lessons
-
Lesson 1 HTTP Fundamentals
Understand requests, responses, methods, headers and status codes, the language every web API speaks.
GET, POST, PUT, DELETEheadersstatus codes 2xx/4xx/5xxidempotency
-
Lesson 2 Calling APIs with HttpClient
Use java.net.http.HttpClient to send requests, set timeouts and handle responses synchronously and asynchronously.
HttpClientHttpRequest builderBodyHandlers.ofStringtimeout
-
Lesson 3 JSON with Jackson
Convert JSON to Java records and back with Jackson, and handle nested data, lists and unknown fields.
JSON object and arrayObjectMapperreadValue / writeValueAsStringTypeReference
-
Lesson 4 Reliable Clients: Errors, Retries and Offline Fallback
Make API clients robust: retry safely, cache the last good data and test without the network.
retry with backofffallbackcache freshnesstest double for HTTP
Practical activity
Build a currency-rate client that fetches rates from a public API, caches the last good result to a file and falls back to it when the network fails.
Expected outcomes
- Reliable API clients
- Correct mapping between JSON and Java types
Assessment
Practical: implement a client for a documented test API; marked on correct parsing, status-code handling and behaviour when the network is unavailable.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.