convert json object to lowercase

Solutions on MaxInterview for convert json object to lowercase by the best coders in the world

showing results for - "convert json object to lowercase"
Karly
26 Jul 2017
1var x = { id: 0, name: "SAMPLe", forms: { formId: 0, id: 0, text: "Sample Text" }};
2
3function lower(obj) {
4  for (var prop in obj) {
5  if (typeof obj[prop] === 'string') {
6    obj[prop] = obj[prop].toLowerCase();
7  }
8  if (typeof obj[prop] === 'object') {
9    lower(obj[prop]);
10    }
11  }
12  return obj;
13}
14
15
16console.log(lower(x));