title: Updating JSON Model in SAPUI5/OpenUI5
body: <p>I have one json model, model/salesOrder.json,</p>
  
  <pre><code>{
    "HeaderSet" : []
  }
  </code></pre>
  
  <p>The initialization,</p>
  
  <pre><code>var SalesOrderModel = new sap.ui.model.json.JSONModel("model/SalesOrder.json");
  sap.ui.getCore().setModel(SalesOrderModel, "SOModel");
  </code></pre>
  
  <p>On the time of creating <code>Sales Order</code>, creating one object which have direct keys like <code>FirstName</code>,<code>LatName</code>,etc. and pushing to this <code>HeaderSet</code> array without any keys.</p>
  
  <pre><code>var salesOrderModel = this.getView().getModel("SOModel");
  var salesOrderData = salesOrderModel.getData();
  salesOrderData.HeaderSet.push(SoObject);
  salesOrderModel.setData(salesOrderData);
  </code></pre>
  
  <p>Suppose I have 3 objects in this model, I need to update a specific object in this model? How can I do that?</p>
  
  <p>Master Page View,</p>
  
  <pre><code>&lt;List id="listMyOrder" growing="true" growingThreshold="10" growingScrollToLoad="true" noDataText="No drafts found" mode="SingleSelectMaster" items="{path : 'SOModel&gt;/HeaderSet' }" select="handleMyOrderSelect"&gt;
         &lt;ObjectListItem title="{SOModel&gt;PurchaseOrderNumber}"&gt;
              &lt;attributes&gt;
                     &lt;ObjectAttribute text="Due Date : {path : 'SOModel&gt;PurchaseOrderDate' }" /&gt;
             &lt;/attributes&gt;
       &lt;/ObjectListItem&gt;
  &lt;/List&gt;
  </code></pre>
  
  <p>Master Page Controller,</p>
  
  <pre><code>handleMyOrderSelect: function (evt) {
      this._showDetail(evt.getParameter("listItem"));
  },
  
  _showDetail: function (item) {
      _salesOrderIDForCart = item.getBindingContext("SOModel").getObject().SalesOrderID
      sap.ui.getCore().getEventBus().publish("nav", "to", {
          id: "SoDetail",
          data: {
              source: "MyOrders",
              SalesOrderID: item.getBindingContext("SOModel").getObject().SalesOrderID,
              context: item.getBindingContext("SOModel")
          }
      });
  }
  </code></pre>
  
  <p>Now, I can directly bind other details in detail page using this context,</p>
  
  <pre><code>&lt;List showSeparators="None" id="tblSummary"&gt;
    &lt;InputListItem label="PO Number"&gt;
      &lt;Label text="{SOModel&gt;PurchaseOrderNumber}" design="Bold"/&gt;
    &lt;/InputListItem&gt;
    &lt;InputListItem label="PO Date"&gt;
      &lt;Label text="{path : 'SOModel&gt;PurchaseOrderDate'}" design="Bold"/&gt;
    &lt;/InputListItem&gt;
  &lt;/List&gt;
  </code></pre>
  
  <p>In this detail page I have a button which will read this context and populate in an editable form. And here I need to update this specific edited item in the correct object of the model.
  I tried by adding a unique dynamic key to each object, but at that time my binding will not work.</p>
  
  <p>Almost same thread here <a href="http://scn.sap.com/thread/3464458" rel="nofollow">http://scn.sap.com/thread/3464458</a> and <a href="http://scn.sap.com/thread/3386927" rel="nofollow">http://scn.sap.com/thread/3386927</a></p>