moving towards real data
This commit is contained in:
parent
ac3c05cb78
commit
40c4a5a37f
8 changed files with 303 additions and 84 deletions
|
|
@ -1697,13 +1697,25 @@ class DataUtils {
|
|||
|
||||
static toSnakeCaseObject(obj) {
|
||||
const newObj = Object.entries(obj).reduce((acc, [key, value]) => {
|
||||
const snakeKey = key.replace(/[A-Z]/g, "_$1").toLowerCase();
|
||||
const snakeKey = key.replace(/[A-Z]/g, (match) => "_" + match.toLowerCase());
|
||||
value = Object.prototype.toString.call(value) === "[object Object]" ? this.toSnakeCaseObject(value) : value;
|
||||
acc[snakeKey] = value;
|
||||
return acc;
|
||||
}, {});
|
||||
console.log("DEBUG: toSnakeCaseObject -> newObj", newObj);
|
||||
return newObj;
|
||||
}
|
||||
|
||||
static toCamelCaseObject(obj) {
|
||||
const newObj = Object.entries(obj).reduce((acc, [key, value]) => {
|
||||
const camelKey = key.replace(/_([a-z])/g, (match, p1) => p1.toUpperCase());
|
||||
value = Object.prototype.toString.call(value) === "[object Object]" ? this.toCamelCaseObject(value) : value;
|
||||
acc[camelKey] = value;
|
||||
return acc;
|
||||
}, {});
|
||||
console.log("DEBUG: toCamelCaseObject -> newObj", newObj);
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
|
||||
export default DataUtils;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue