{"ScriptPreparationCode":"function obj2Array2(obj, prefix) {\r\n var arr = [];\r\n\r\n _.forIn(obj, function (value, key) {\r\n if (_.isObject(value) \u0026\u0026 !_.isEmpty(value)) {\r\n arr = _.concat(arr, obj2Array2(value, key));\r\n }\r\n else {\r\n arr.push(key);\r\n try {\r\n arr.push(JSON.stringify(value));\r\n }\r\n catch (e) {\r\n arr.push(value);\r\n }\r\n }\r\n\r\n });\r\n\r\n\r\n if (_.isString(prefix) \u0026\u0026 !_.isEmpty(prefix)) {\r\n return _.map(arr, function (arg, index) {\r\n if (index % 2 === 0) { return \u0060${prefix}.${arg}\u0060; }\r\n return arg;\r\n });\r\n }\r\n\r\n return arr;\r\n }\r\n\r\nfunction obj2Array (object, prefix) {\r\n var arr = [];\r\n\t\r\n \tObject.keys(object).forEach(function (key) {\r\n\t\tconst value = object[key];\r\n\t\t\r\n\t\tif (typeof value === \u0027object\u0027 \u0026\u0026 Object.keys(value).length !== 0) {\r\n let prefixedKey = (prefix \u0026\u0026 \u0060${prefix}.${key}\u0060) || key,\r\n \r\n returnedArray = obj2Array(value, prefixedKey);\r\n\r\n arr = arr.concat(returnedArray);\r\n\r\n return;\r\n }\r\n\r\n arr.push((prefix \u0026\u0026 \u0060${prefix}.${key}\u0060) || key);\r\n arr.push(JSON.stringify(value));\r\n\r\n\t});\r\n\r\n return arr;\r\n}\r\n\r\nfunction obj2Array3(obj, prefix, arr = []) {\r\n if (!obj) { return arr; }\r\n\r\n\r\n const usePrefix = prefix \u0026\u0026 typeof prefix === \u0027string\u0027;\r\n\r\n\r\n usePrefix \u0026\u0026 (prefix \u002B= \u0027.\u0027);\r\n\r\n\r\n Object.keys(obj).forEach(function (key) {\r\n const value = obj[key];\r\n\r\n usePrefix \u0026\u0026 (key = prefix \u002B key);\r\n\r\n if (typeof value === \u0027object\u0027 \u0026\u0026 Object.keys(value).length !== 0) {\r\n obj2Array3(value, key, arr);\r\n }\r\n\r\n else {\r\n arr.push(key, JSON.stringify(value));\r\n }\r\n });\r\n\r\n\r\n return arr;\r\n\r\n }\r\n\r\n var objToTest = {\r\n user: {\r\n id: 123,\r\n data: {\r\n username: \u0027marvin\u0027,\r\n email: \u0027marvin@heartofgold.ship\u0027\r\n },\r\n tags: [\u0027robot\u0027, \u0027depressed\u0027, \u0027brain the size of a planet\u0027]\r\n }\r\n }\r\n","TestCases":[{"Name":"Current Method","Code":"obj2Array2(objToTest);","IsDeferred":false},{"Name":"My Method (added empty check)","Code":"obj2Array(objToTest);","IsDeferred":false},{"Name":"Yashish Method (added empty check)","Code":"obj2Array3(objToTest);","IsDeferred":false}]}