Answers for "convert json object to lowercase"

0

convert json object to lowercase

var x = { id: 0, name: "SAMPLe", forms: { formId: 0, id: 0, text: "Sample Text" }};

function lower(obj) {
  for (var prop in obj) {
  if (typeof obj[prop] === 'string') {
    obj[prop] = obj[prop].toLowerCase();
  }
  if (typeof obj[prop] === 'object') {
    lower(obj[prop]);
    }
  }
  return obj;
}


console.log(lower(x));
Posted by: Guest on July-07-2020

Code answers related to "convert json object to lowercase"

Code answers related to "Javascript"

Browse Popular Code Answers by Language