@machaval is correct you got to traverse.
There is a way and depending on your background it maybe simple. This should be a good start even if its a bit inflexible:
%dw 2.0
output application/dw
var ds = [
{
a: "1",
b: "2",
c: "str",
d: ["1","2","str","false"],
e: "true"
},
{
a: "1",
b: "2",
c: "str",
d: ["1","2","str","false"],
e: "true"
}
]
import try,orElseTry,orElse from dw::Runtime
// Overloaded functions that traverse the types that I know
// my data structure contains. I only traverse arrays and objects
// and the combination thereof. If you expect more types in your
// data you will have to add one overloaded function per datatype
// you expect to have up and beyond what I show below.
fun traverse(a: Array) = a map traverse($)
fun traverse(o: Object) = o mapObject {($$): traverse($)}
fun traverse(s: String) =
try(() -> s as Number)
orElseTry(() -> s as Boolean)
orElse(s)
---
traverse(ds)
edit: to include booleans