title: AngularJS - Create dynamic properties to an object/model from json
body: <p>OK, we all know this works:</p>
  
  <pre><code>vm.myObject = { 
               required : "This field requires data",
               .....
             }
  </code></pre>
  
  <p>But how can I create that same object dynamically when the property 'keys' and 'values' come from a json file, eg:</p>
  
  <p>json: </p>
  
  <pre><code>     [
         { "key" :"required", "value": "This field requires data"},
           .....
       ]
  </code></pre>
  
  <hr>
  
  <p>service: </p>
  
  <pre><code>  var myObject = {}
    DynamicObjSvc.get()
          .success(function(data){
              data.forEach(function(item){
                 // pass each key as an object property
                 // and pass its respective value
                  ?????????
              })
          .....
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Kavemen was mostly correct, this turned out to be the solution:</p>
  
  <pre><code>    var myObject = {};
      DynamicObjSvc.all()
          .success(function(data){
             angular.forEach(data, function(msg) {
                 myObject[msg.key] = msg.value; &lt;-- his answer was incorrect here
              });
              $fgConfigProviderRef.validation.message(myObject);
          })
          .error(function(err){
              console.log(err.message);
          })
  </code></pre>