Leniency #5
Replies: 2 comments 1 reply
-
That's not supported at the DSL level, but I believe it's a good idea that can be implemented in a future release. For the moment the only way to do it, it's like this: @Test
fun `Assignments are working correctly with inner JSONs and lambdas`() {
testFromDirectory("assign/jsoninjson") {
"author" /= json {
"fullName" /= {
sourceCtx().read("$.books[1].author")
}
"firstName" /= { targetCtx().read<String>("$.fullName").split(" ")[0] }
"lastName" /= { targetCtx().read<String>("$.fullName").split(" ")[1] }
- "fullName"
"book" /= {
try {
sourceCtx().read("$.books[1].title1")
} catch (e: PathNotFoundException) {
""
}
}
"address" /= json {
"country" /= "UK"
}
}
}.doTest()
} You need to catch the exception "book" /= {
try {
sourceCtx().read("$.books[1].title1")
} catch (e: PathNotFoundException) {
""
}
} Do you have any suggestions on how to implement this, from a design perspective? Andrei |
Beta Was this translation helpful? Give feedback.
-
After using the lib for most of the year, here's what we came up with, with success
But what would be nice would be an operator of the sort but over all, love the lib ! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
how do I make the lib more lenient and not fail on a known json path that is missing ?
So , if in the code I'm expecting $.company.location.address and the address part is not in the json that I'm processing, how can I just ignore this and not fail ?
tks
Beta Was this translation helpful? Give feedback.
All reactions