'Compose DslPart for complex json

Please could someone assist me create a dslPart object for the below json. I'm stuck at the components array within the content object for type: Component 2. I'm not sure how to compose the nested object

[
   {
      "type":"Component1",
      "content":{
         "title":"Test Component 1"
      }
   },
   {
      "type":"Component2",
      "content":{
         "components":[
            {
               "type":"SubComponent1",
               "content":{
                  "title":"Sub title 1"
               }
            },
            {
               "type":"SubComponent2",
               "content":{
                  "subtitle":"Sub title 2",
                  "title":"Title",
                  "prop": "test"
               }
            }
         ]
      }
   },
   {
      "type":"Component3",
      "content":{
         "caption":"3",
         "value":"Test"
      }
   }
]

My kotlin code so far is below:

 PactDslJsonArray.arrayEachLike()
        .stringType("type", "Component1")
        .`object`(
            "content",
            PactDslJsonBody()
                .stringType("Title", "Test Component 1")
        )
         .stringType("type", "Component 2")
        .`object`(
            "content",

        )


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source