title: knockout.mapping - convert whole object included nested objects to knockout.observable
body: <p>I am using knockout.mapping to convert my javascript object into a knockout observable. Inside this javascript object is a nested object and this nested object is being converted but it is in the wrong place. So when my view tries to bind the data it can't because the mapping has moved the nested object to the root.</p>
  
  <p><strong>JSON data</strong></p>
  
  <pre><code>[
      {
          "brandName": "Knockando Single Malt Whisky",
          "categoryDescription": "Alcohol - Whisky &amp; Bourbon",
          "dateAmended": "2008-01-28T10:05:00.000Z",
          "defaultSearchName1": "KnockandoSingleMaltWhisky",
          "defaultSearchName2": "Knockando Single Malt Whisky",
          "advertiser": {
              "activities": "Motor dealers",
              "additionalInfo": "",
              "advertiserName": "Parks of Hamilton Ltd",
              "alfRank": 3311,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "Trade as Parks Motor Group.\nAlternative email: coachhire@park.uk.com, admin@park-uk.com, Info@park.uk.com.",
              "numberOfEmployees": 1000,
              "outdoorRank": 1426,
              "pressRank": 5159,
              "radioRank": 675,
              "tVRank": 1810
          }
      },
      {
          "brandName": "Tesco Petrol/Diesel Fuel",
          "categoryDescription": "Petrol &amp; Service Stations",
          "dateAmended": "2013-07-10T15:17:00.000Z",
          "defaultSearchName1": "TescoPetrol/DieselFuel",
          "defaultSearchName2": "Tesco Petrol/Diesel Fuel",
          "advertiser": {
              "activities": "Furnitures",
              "additionalInfo": "",
              "advertiserName": "Pine &amp; Things Ltd",
              "alfRank": 4570,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "Trade as P&amp;T.\nAlternative email: info@pineandthings.co.uk.",
              "numberOfEmployees": 25,
              "outdoorRank": 1426,
              "pressRank": 2851,
              "radioRank": 2449,
              "tVRank": 1810
          }
      },
      {
          "brandName": "Tesco Electrical Products",
          "categoryDescription": "Supermarkets &amp; Multiple Retailers",
          "dateAmended": "2013-07-10T15:52:00.000Z",
          "defaultSearchName1": "TescoElectricalProducts",
          "defaultSearchName2": "Tesco Electrical Products",
          "advertiser": {
              "activities": "Bridalwear",
              "additionalInfo": "",
              "advertiserName": "Phil Collins Bridal Collection Ltd",
              "alfRank": 4094,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "Alternative email: enquiries@philcollinsbridal.co.uk, pcbridal@aol.com.",
              "numberOfEmployees": 30,
              "outdoorRank": 1426,
              "pressRank": 2487,
              "radioRank": 2449,
              "tVRank": 1810
          }
      },
      {
          "brandName": "Tesco Bank Insurance Ranges",
          "categoryDescription": "Insurance Ranges",
          "dateAmended": "2012-01-05T12:30:00.000Z",
          "defaultSearchName1": "TescoBankInsuranceRanges",
          "defaultSearchName2": "Tesco Bank Insurance Ranges",
          "advertiser": {
              "activities": "Nutition supplements",
              "additionalInfo": "",
              "advertiserName": "PhD Nutrition Ltd",
              "alfRank": 4107,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "Alternative email: info@phd-supplements.com.\nThere is no alternative head office landline number.",
              "numberOfEmployees": 30,
              "outdoorRank": 1426,
              "pressRank": 2500,
              "radioRank": 2449,
              "tVRank": 1810
          }
      },
      {
          "brandName": "Tesco Clubcard",
          "categoryDescription": "Loyalty &amp; Incentive Schemes",
          "dateAmended": "2008-03-26T14:05:00.000Z",
          "defaultSearchName1": "TescoClubcard",
          "defaultSearchName2": "Tesco Clubcard",
          "advertiser": {
              "activities": "",
              "additionalInfo": "",
              "advertiserName": "British Regional Airlines Group PLC",
              "alfRank": 6031,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "",
              "numberOfEmployees": 0,
              "outdoorRank": 1426,
              "pressRank": 5159,
              "radioRank": 2449,
              "tVRank": 1810
          }
      },
      {
          "brandName": "Royal Mail Corporate",
          "categoryDescription": "Public Services - Corporate",
          "dateAmended": "2010-06-04T11:45:00.000Z",
          "defaultSearchName1": "RoyalMailCorporate",
          "defaultSearchName2": "Royal Mail Corporate",
          "advertiser": {
              "activities": "",
              "additionalInfo": "",
              "advertiserName": "Yorkshire Power Group Ltd",
              "alfRank": 6031,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "",
              "numberOfEmployees": 0,
              "outdoorRank": 1426,
              "pressRank": 5159,
              "radioRank": 2449,
              "tVRank": 1810
          }
      },
      {
          "brandName": "E.ON Surf &amp; Save ISP",
          "categoryDescription": "Telecom - Internet Service Providers",
          "dateAmended": "2007-11-23T12:25:00.000Z",
          "defaultSearchName1": "E.ONSurf&amp;SaveISP",
          "defaultSearchName2": "E.ON Surf &amp; Save ISP",
          "advertiser": {
              "activities": "",
              "additionalInfo": "",
              "advertiserName": "Stagecoach Ltd",
              "alfRank": 6031,
              "cinemaRank": 286,
              "directMailRank": 1291,
              "internetRank": 1988,
              "notes": "",
              "numberOfEmployees": 0,
              "outdoorRank": 1426,
              "pressRank": 5159,
              "radioRank": 2449,
              "tVRank": 1810
          }
      }
  ]
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code> // Get JSON from local storage and convert to js object
   var objBrands = new Object(ko.mapping.fromJSON(localStorage.getItem('Brands')));
  
   // Convert from object to observable
   brands = ko.mapping.fromJS(objBrands)
  </code></pre>
  
  <p><strong>My object with data before being converted to observable</strong></p>
  
  <p><img src="https://i.stack.imgur.com/t0QIP.png" alt="enter image description here"></p>
  
  <p><strong>After conversion</strong></p>
  
  <p><img src="https://i.stack.imgur.com/24BGz.png" alt="enter image description here"></p>
  
  <p>In screenshot two - advertiser is in the wrong place. I want it inside [0] but the ko.mapping parsed my object and put it there.</p>