JSON data serialization I'm parsing a JSON data send from server to new JSON Object using JavaScript.

JSON data from server will be in this format 

SERVER JSON:

{
  'serverFromDate': '15/07/1988',
  'serverToDate': 123,
  'hdnUserName' : 'User',
  'hdnRole' :'Admin',
  'hdncmbRoles':[{'text':'Admin', 'hdnvalue':'admin'},
           {'text':'Client', 'hdnvalue':'client'}]
}


and I'm converting this JSON to below format

CLIENT JSON:

{
      'clientFromDate': '15/07/1988',
      'clientToDate': 123,
      'txtUserName' : 'User',
      'txtRole' :'Admin',
      'cmbRoles':[{'text':'Admin', 'value':'admin'},
               {'text':'Client', 'value':'client'}]
    }


My Conversion Util is like this...I will check for every server key is present in the Server JSON, if it there then i will added it to the client JSON.



var j_Utils = {
  getValueOf: function(json) {
    return function(key) {
      return json[key];
    }
  },

  hasKeyOf: function(json) {
    return function(key) {
      return json.hasOwnProperty(key);
    }
  }
};

function getMappedData(data) {
  var jObj = {},
    getValueOf = j_Utils.getValueOf(data).bind(j_Utils),
    hasKeyOf = j_Utils.hasKeyOf(data).bind(j_Utils);

  if (hasKeyOf('serverFromDate'))
    jObj['clientFromDate'] = getValueOf('serverFromDate');
  if (hasKeyOf('serverToDate'))
    jObj['clientToDate'] = getValueOf('serverToDate');

  //..........................................
  // TOO MANY DATA OR MAY NOT HAVE ALL TIME
  //..........................................

  return jObj;
};

var clientData = getMappedData({
  'serverFromDate': '15/07/1988',
  'serverToDate': 123
});
console.table(clientData);




Some time these data will be huge, so I'm supposed to write a lengthy javascript code which does the same operation from mapping one value to other. So I want to simplify this JavaScript code in a more efficient and simpler way. The keys from server and client are different (yeah there may be some prefix and suffix or some keys are entirely different), is there any possible ways to simplify these steps in ES6/ES5?
You are right, this can be simplified, quite a lot actually!

First, I'm not sure I see the value of the j_utils object. The methods are simple enough that there isn't much value in creating a function for them, and I'm not sure I see the value of currying here.

That said, it cleans up nicely with arrow functions. 

const j_Utils = {
  getValueOf: json =&gt; key =&gt; json[key],
  hasKeyOf: json =&gt; key =&gt; json.hasOwnProperty(key)
}


Now the getMappedData function, if I'm not mistaken you currently have a lot more if statements that essentially follow this pattern:

if (hasKeyOf(serverKey)) {
  result[clientKey] = getValueOf(serverKey)
}


This is a great opportunity to use some array methods to move your code into configuration. Here's one way to do it. 

function getMappedData(data) {
  var clientServerMapping = [
    { client: 'clientFromDate', server: 'serverFromDate' },
    { client: 'clientToDate', server: 'serverToDate' },
  ];

  const getValueOf = j_Utils.getValueOf(data);
  const hasKeyOf = j_Utils.hasKeyOf(data);

  return clientServerMapping
    .filter(item =&gt; hasKeyOf(item.server))
    .reduce((carry, item) =&gt; {
        carry[item.client] = getValueOf(item.server);
        return item;
    }, {});
};


And here's the method without requiring the j_Utils helpers. 



function getMappedData(data) {
  const clientServerMapping = [
    { client: 'clientFromDate', server: 'serverFromDate' },
    { client: 'clientToDate', server: 'serverToDate' },
  ];

  return clientServerMapping
    .filter(item =&gt; data.hasOwnProperty(item.server))
    .reduce((carry, item) =&gt; {
      carry[item.client] = data[item.server];
      return carry;
    }, {});
}

let clientData = getMappedData({
  'serverFromDate': '15/07/1988',
  'serverToDate': 123
});
console.log(clientData);




Lastly, I didn't take this approach as your keys might differ, but if all that changes between your object keys input and your object keys output is the word 'server' to 'client', you could just loop through, replacing each key, something like the following. 



function getMappedData(data) {
  const result = {};
  
  Object.keys(data).forEach(key =&gt; {
    result[key.replace('server', 'client')] = data[key];
  });
  
  return result;
}

let clientData = getMappedData({
  'serverFromDate': '15/07/1988',
  'serverToDate': 123
});
console.log(clientData);