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.

Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68

1 Answers1

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

ibexit
  • 3,465
  • 1
  • 11
  • 25