Most integration work isn’t about calling APIs.
It’s about reshaping data.
Different systems send JSON in different formats, and almost every integration needs:
- Renaming fields
- Aggregating values
- Handling missing data
- Producing a clean, predictable output
In this post, I’ll show how complex JSON → JSON transformation can be done cleanly in Spubhi, without loops, glue code, or custom scripts.
The Problem: Real JSON Is Never Flat
Let’s start with a realistic payload received via a webhook:
{
"invoiceId": "INV-101",
"customer": {
"name": {
"first": "Ravi",
"last": "Sharma"
}
},
"items": [
{ "name": "Laptop", "price": 50000.258 },
{ "name": "Mouse", "price": 800.756 }
]
}
What downstream systems usually want is something simpler:
{
"invoiceId": "INV-101",
"customerName": "Ravi Sharma",
"itemCount": 2,
"totalAmount": 50801.014
}
This requires:
- Navigating nested fields
- Combining values
- Aggregating arrays
- Preserving decimal precision
The Traditional Way (and Why It’s Painful)
In most platforms, this means:
- Writing loops
- Manually summing values
- Handling nulls defensively
- Worrying about floating-point precision
The transformation logic ends up scattered and hard to maintain.
The Spubhi Way: JSON-First Transformation
Spubhi treats everything as JSON internally, even if the input was XML or another format.
The transformation logic looks like this:
{
"invoiceId": payload.invoiceId,
"customerName": payload.customer.name.first + " " + payload.customer.name.last,
"itemCount": sizeOf(payload.items),
"totalAmount": sumBy(payload.items, "price")
}
That’s it.
No loops.
No glue code.
No precision loss.
Why This Works Well
1. JSON-First by Design
You always work with JSON, regardless of how the data came in.
2. Built-in Aggregation
Functions like sizeOf and sumBy are first-class, not hacks.
3. Decimal-Safe Calculations
Sums preserve natural decimal values instead of forcing rounding.
4. One Concept per Line
Each output field clearly shows:
Where data comes from
How it’s derived
Why This Matters
Integration code tends to live for years.
The simpler the transformation logic, the easier it is to:
- Debug
- Extend
- Hand off to another developer
By keeping transformations declarative and JSON-focused, Spubhi reduces the mental overhead that usually comes with integration work.
Final Thoughts
Most integration platforms can transform JSON.
The difference is how much work you have to do to get there.
If your integrations involve:
- Webhooks
- Event-driven payloads
- Aggregations
- Complex JSON reshaping
A JSON-first approach makes a noticeable difference.
Top comments (0)