Serialization
35 → Serialization & Data Formats
Previous: 34 Modules → Next: 36 Performance & Build
▶️ mvn test -f pkg20serialization/pom.xml
Formats compared
| Format | Human-readable | Schema | Cross-language | Use |
|---|---|---|---|---|
| JSON (Jackson) | Yes | Optional | Yes | REST APIs, config |
| XML (JAXB) | Yes | Yes (XSD) | Yes | Legacy enterprise |
| YAML | Yes | Loose | Yes | Config files |
| Protobuf | No | .proto required |
Yes | gRPC, high perf |
| Avro | No | Schema registry | Yes | Kafka pipelines |
| Java serialization | No | Java-only | No | ▶️ avoid for external data |
Jackson example
1ObjectMapper mapper = new ObjectMapper();2String json = mapper.writeValueAsString(user);3User back = mapper.readValue(json, User.class);▶️ Never deserialize untrusted Java native serialization · remote code execution risk.
Related → Serialization.md
Related → 11 I/O & Serialization
Next → 36 Performance & Build