Urgent.News

What's breaking now, across thousands of outlets.

Tech

Processing ISO 20022 payment XML in Rust: detection, typed parsing and JSON

ISO 20022 payment messages are versioned XML documents. In an integration service, the first task may be to identify a message and read a few business fields. A later stage may need typed field access, arithmetic on an amount, and serialization for another system. This walkthrough uses rust_iso20022 0.1.6 , an Apache-2.0 toolkit with a Rust 1.85 core MSRV. Its generated model collection covers…

ISO 20022 payment messages are XML documents that can be versioned and have various business fields. In an integration service, the first step is to identify the message and access some business fields. Later, typed field access, arithmetic on an amount, and serialization for another system may be required. The rust_iso20022 0.1.6 toolkit, with a Rust 1.85 core MSRV, covers 1,130 message versions across 32 business areas.

We will use the pacs.008.001.08 version for this walkthrough. The XML below is a synthetic, minimal teaching sample. It demonstrates the SDK's parsing APIs but does not perform complete XSD or banking-scheme validation.

To start, create a Rust application and add the rust_iso20022 library. Replace the src/main.rs file with the provided complete program. This program uses the rust_iso20022::detect function to read the message identity from its XML namespace and prints the message name. It also uses MxNode for generic tree access and parses the XML to access the message ID and amount. The amount is then printed along with its currency.

Next, add typed parsing, JSON, and decimal conversion to the project by using the rust_iso20022@0.1.6 library with the model-pacs, serde, and convert features. Replace the src/main.rs file with the provided complete program. This updated program uses the rust_iso20022 generated model for pacs.008.001.08, serde for JSON serialization and deserialization, and convert for decimal conversion. It prints the message ID, amount, and doubled amount, and also performs an XML round trip by serializing and reparsing the document.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Image to PDF Without Uploading: A Private Alternative

Image to PDF Without Uploading: A Private Alternative Turning images into a PDF is one of those everyday tasks — a batch of receipts for expenses, a signed contract you photographed, ID documents for…

  • Browser-local tools convert images to PDFs without uploading files to servers.
  • Desktop apps are paid solutions, only usable on installed devices.
  • Browser-local tools work on any modern browser, keeping files on your device.

More from Thursday 8 October →