Help with Pact Lambda JVM DSL

64 views
Skip to first unread message

Jim T

unread,
Sep 8, 2021, 1:21:15 PM9/8/21
to Pact Support
Hi, I have a JSON structure as below which I am trying to model: 

{
  "answers": {
    "QUESTION_1": ["answer1"],
    "QUESTION_2": ["answer2", "answer3"]
  }
}

Where the "answers" keys can dynamically change and are not set - dependent on what questions the user answers. 

I am trying to map this and I presumed something like

allAnswers.eachKeyMappedToAnArrayLike("key1", ...

from:

eachKeyMappedToAnArrayLike(String exampleKey, Consumer<LambdaDslObject> nestedObject) {

This should would work but it appears that it always expects to return an object rather than an array. Does anyone know how I can achieve this with the DSL.

 I've run into a brick wall at the moment. If I specify concrete key names then I am good, but with variable keys it doesn't look like there is a way to do this? 

Cheers! 
Reply all
Reply to author
Forward
0 new messages