title: Create complex object in Python based on property names in dot notation
body: <p>I am trying to create a complex object based on metadata I have. It is an array of attributes which I am iterating and trying to create a dict. For example below is the array:</p>
  <pre><code>[
      &quot;itemUniqueId&quot;,
      &quot;itemDescription&quot;,
      &quot;manufacturerInfo[0].manufacturer.value&quot;,
      &quot;manufacturerInfo[0].manufacturerPartNumber&quot;,
      &quot;attributes.noun.value&quot;,
      &quot;attributes.modifier.value&quot;,
      &quot;attributes.entityAttributes[0].attributeName&quot;,
      &quot;attributes.entityAttributes[0].attributeValue&quot;,
      &quot;attributes.entityAttributes[0].attributeUOM&quot;,
      &quot;attributes.entityAttributes[1].attributeName&quot;,
      &quot;attributes.entityAttributes[1].attributeValue&quot;,
      &quot;attributes.entityAttributes[1].attributeUOM&quot;,
  ]
  </code></pre>
  <p>This array should give an output as below:</p>
  <pre><code>{
      &quot;itemUniqueId&quot;: &quot;&quot;,
      &quot;itemDescription&quot;: &quot;&quot;,
      &quot;manufacturerInfo&quot;: [
          {
              &quot;manufacturer&quot;: {
                  &quot;value&quot;: &quot;&quot;
              },
              &quot;manufacturerPartNumber&quot;: &quot;&quot;
          }
      ],
      &quot;attributes&quot;: {
          &quot;noun&quot;: {
              &quot;value&quot;: &quot;&quot;
          },
          &quot;modifier&quot;: {
              &quot;value&quot;: &quot;&quot;
          },
          &quot;entityAttributes&quot;: [
               {
                   &quot;attributeName&quot;: &quot;&quot;,
                   &quot;attributeValue&quot;: &quot;&quot;,
                   &quot;attributeUOM&quot;: &quot;&quot;
               },
               {
                  &quot;attributeName&quot;: &quot;&quot;,
                  &quot;attributeValue&quot;: &quot;&quot;,
                  &quot;attributeUOM&quot;: &quot;&quot;
               }
          ]
      }
  }
  </code></pre>
  <p>I have written this logic but unable to get the desired output. It should work on both object and array given the metadata.</p>
  <pre><code>source_json = [
      &quot;itemUniqueId&quot;,
      &quot;itemDescription&quot;,
      &quot;manufacturerInfo[0].manufacturer.value&quot;,
      &quot;manufacturerInfo[0].manufacturerPartNumber&quot;,
      &quot;attributes.noun.value&quot;,
      &quot;attributes.modifier.value&quot;,
      &quot;attributes.entityAttributes[0].attributeName&quot;,
      &quot;attributes.entityAttributes[0].attributeValue&quot;,
      &quot;attributes.entityAttributes[0].attributeUOM&quot;,
      &quot;attributes.entityAttributes[1].attributeName&quot;,
      &quot;attributes.entityAttributes[1].attributeValue&quot;,
      &quot;attributes.entityAttributes[1].attributeUOM&quot;,
  ]
  
  for row in source_json:
      propertyNames = row.split('.')
      temp = ''
      parent = {}
      parentArr = []
      parentObj = {}
      # if len(propertyNames) &gt; 1:
      arrLength = len(propertyNames)
      for i, (current) in enumerate(zip(propertyNames)):
          if i == 0:
              if '[' in current:
                  parent[current]=parentArr
              else:
                  parent[current] = parentObj
              temp = current
          if i &gt; 0 and i &lt; arrLength - 1:
              if '[' in current:
                  parent[current] = parentArr
              else:
                  parent[current] = parentObj
              temp = current
          if i == arrLength - 1:
              if '[' in current:
                  parent[current] = parentArr
              else:
                  parent[current] = parentObj
              temp = current
              # temp[prev][current] = &quot;&quot;
      # finalMapping[target] = target
  print(parent)
  </code></pre>