Why structured payload handling matters
IBM i often needs to exchange data with web services, integration buses, and mobile or desktop front ends. JSON and XML are the common formats that make that exchange possible. The platform does not need to abandon its core strengths to participate in that world; it needs a clean transform layer.
The real goal is to keep business rules stable while the interface layer handles different payload formats and field names.

At a glance
A good integration flow separates the external message format from the internal model so changes are easier to control.
| Concept | What it means | What to watch |
|---|---|---|
| JSON | A compact object format used heavily by APIs | Keep field names stable and predictable. |
| XML | A verbose structured format still used by many systems | Preserve schemas and namespaces carefully. |
| Parser | The component that reads the payload | Validate inputs before business logic runs. |
| Transform | The mapping layer between formats | Keep this separate from the core application rules. |
Why this matters for daily work
JSON is often the easiest format for web integrations, while XML still appears in older but critical interfaces. IBM i teams benefit when they can handle both with the same discipline: parse carefully, validate early, and keep the transformation code small enough to test independently.
Core concepts
| Concept | Practical meaning | Review point |
|---|---|---|
| Canonical model | Define one internal structure and map both JSON and XML into it instead of letting every format reach business logic directly. | One model should own the truth. |
| Encoding discipline | Make sure special characters, numeric formats, and date formats are handled consistently. | Test the edge cases, not just the happy path. |
| Validation | Reject malformed payloads before the request gets any deeper into the application. | Stop early and report clearly. |
| Versioning | Payload schemas evolve, so the integration layer needs a change process just like the code does. | Treat payload changes as source changes. |

Practical example
An order status service can read a JSON payload from a web client, map the fields into an internal order structure, and then use the same core logic that another XML-based integration also uses.
Implementation checklist
- Define one canonical internal data model first.
- Map JSON and XML into that model with a thin transform layer.
- Validate field presence, data type, and encoding before continuing.
- Return a stable error format when the payload is invalid.
- Test non-ASCII characters, escaped symbols, and versioned fields.
The transform layer should be small enough that you can prove it works without reading the rest of the application.
Common mistakes
- Mixing protocol details and business logic in the same routine.
- Assuming all payloads are ASCII and simple.
- Changing field names without versioning the interface.
- Letting XML and JSON map into different internal structures for the same concept.