| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function formatGoogleInputs(obj) { |
| const formattedObj = {}; |
|
|
| for (const key in obj) { |
| if (Object.prototype.hasOwnProperty.call(obj, key)) { |
| const value = obj[key]; |
|
|
| |
| if (Array.isArray(value)) { |
| formattedObj[key] = { list_val: value.map((item) => formatGoogleInputs(item)) }; |
| } |
| |
| else if (typeof value === 'object' && value !== null) { |
| formattedObj[key] = formatGoogleInputs(value); |
| } |
| |
| else if (typeof value === 'number') { |
| formattedObj[key] = Number.isInteger(value) ? { int_val: value } : { float_val: value }; |
| } |
| |
| else { |
| formattedObj[key] = { string_val: [value] }; |
| } |
| } |
| } |
|
|
| return { struct_val: formattedObj }; |
| } |
|
|
| module.exports = formatGoogleInputs; |
|
|