📌  相关文章
📜  将 json 对象转换为小写 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:14.643000             🧑  作者: Mango

代码示例1
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));