title: Fill empty object with part of the data from another object JavaScript
body: <p>I have an empty object that's represented like this:</p>
  
  <pre><code>myObj = {
   myObjName = null;
   myObjType = null;
   myObjOcc = null;
  }
  </code></pre>
  
  <p>And there is an object with objects represented like this:</p>
  
  <pre><code>mainObj = {
      "Ob1": {
          "id": 1,
          "name": "Ob1",
          "properties": {
              "attName": "A1",
              "attType": "string",
              "attOccurance": "minOccurs="1""
          },
      },
      "Ob2": {
           "id": 101,
           "name": "Ob2",
           "properties": {
               "attName": "B1",
               "attType": "string",
               "attOccurance": "minOccurs="1""
           },
       }
       "Ob3": {
            "id": 10001,
            "name": "Ob3",
            "properties": {
                "attName": "C1",
                "attType": "string",
                "attOccurance": "minOccurs="1""
                },
         }
  }
  </code></pre>
  
  <p>I have to insert the data from the objects in <strong>mainObj</strong> to <strong>myObj</strong>.</p>
  
  <p>The mapping is supposed to be like this:</p>
  
  <pre><code>myObjName = attName
  myObjType = attType
  myObjOcc = attOccurance
  </code></pre>
  
  <p>Another thing taken into account has to be <strong>id</strong> in mainObj, because <strong>Ob2</strong> has to be nested inside <strong>Ob1</strong> and <strong>Ob3</strong> has to be nested inside <strong>Ob2</strong></p>
  
  <p>So myObj is suppose to look like this:</p>
  
  <pre><code>myObj = {
      "Ob1": {
          "myObjName": "A1",
          "myObjType": "string",
          "myObjOcc": "minOccurs="1""
          "Ob2": {
              "myObjName": "B1",
              "myObjType": "string",
              "myObjOcc": "minOccurs="1""
              "Ob3": {
                  "myObjName": "C1",
                  "myObjType": "string",
                  "myObjOcc": "minOccurs="1""
              }
          }
     }
  }
  </code></pre>
  
  <p>I have this part in the code that determines which level is every object:</p>
  
  <pre><code>for each(var oneObj in mainObj){
      .
      .
      switch (true) {
                   case  oneObj.id &lt; 100: levelId=1; break;
                   case  oneObj.id &lt; 10000: levelId=2; break;
                   case  oneObj.id &lt; 1000000: levelId=3; break;
      }
      .
      .
  }
  </code></pre>
  
  <p>Please if anyone can help me how can I do this?</p>