-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
Problem
JFlat's toCSV method can only iterate over JSON arrays to produce CSV rows. When a JSON structure uses an object with dynamic keys (e.g. a map of items keyed by UID, hash, or any arbitrary string), there is no way to expand each child into a separate CSV row.
For example, many REST APIs return collections as objects rather than arrays:
{
"members": {
"abc123": { "id": 0, "name": "Drive 0" },
"def456": { "id": 1, "name": "Drive 1" }
}
}Currently, calling toCSV("/members", ...) produces a single row for the members object itself, instead of one row per child entry. The only workaround is to pre-process the JSON externally to convert the object values into an array before passing it to JFlat.
Expected Behavior
JFlat should support a wildcard notation in the entry key path (e.g. /members/*) that expands all direct children of an object into individual CSV rows, just as arrays are automatically expanded today.
This should work with:
- Simple properties:
/members/*with properties likeid,name - Nested properties:
/members/*with properties likemanufacturing/serialNumber,type/default - Parent references: The existing
../syntax should continue to work from wildcard-expanded entries
Since * is a valid JSON key, a way to refer to a literal * property (e.g. via escaping) should also be provided to avoid ambiguity.