0

Given the following nested object

{
  "nestedParent":{
    "type":"nested",
    "dynamic":"true",
    "properties":{
      ...
    }
  }
}

I need all its properties to be of the nested type too. How do I generate a mapping for an unknown number of nested children?

Something functionally equal to:

{
  "nestedParent":{
    "type":"nested",
    "dynamic":"true",
    "properties":{

      "nestedChild1":{
        "type":"nested",
        "dynamic":"true",
        "properties":{
          ...
        }
      },
      "nestedChild2":{
        "type":"nested",
        "dynamic":"true",
        "properties":{
          ...
        }
      },
      "nestedChild3":{
        "type":"nested",
        "dynamic":"true",
        "properties":{
          ...
        }
      },

      ...
    }
  }
}

I do know the structure of the nested children but I do not know their keys/names.

1

1 Answer 1

0

You will need some generic data structure like a Map of Maps in order to map the unknown structure. In Java, there are many implementations for this problem. For example, please have a look on this post, which describes how to handle (de)serialization of unknown json using te jackson mapper: https://www.baeldung.com/jackson-json-node-tree-model

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.