does anyone has any idea how to achieve it
# pact-jvm
a
does anyone has any idea how to achieve it
p
have you tried
Copy code
au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody
?
for example:
Copy code
newJsonBody(body -> {
           body.minArrayLike("users", 2, users -> {
               users.stringType("name");
               users.integerType("age");
           });
        });
you can return this result from you method and use inside .body() with PactDslWithProvider builder
a
thanks for the answer
but i am asking if i dont want to give property name "users"
as it is just an array of json objects
p
in the example above array of arrays is used, but it can be applied for array of objects as well
b
Yeah, I think there's a way to make the root object an array, it's probably just hard to find in the docs.
As an aside, I'd recommend using objects (not arrays) as the root element in JSON responses, for extensibility. It's much easier to add new fields to an object (backwards-compatible change), than wrapping your root array in an object later (backwards-incompatible change).
(This is probably part of the reason that it's less documented)
a
Hey, I used new PactDslJsonArray().arrayMinlike(1, new PactDslJsonBody()) but i am getting array of array