JSFiddle - React, Tailwind, and code Playground
JavaScript
// Convert Nested Json to Flat Json
// Check the final json in firebug console.
var fullData = {
"message": {
"welcome": "Welcome, select your language.",
"destination": {
"title": "Select a destination."
}
}
};
var finalData = [];
loopJson(fullData.data);
function loopJson(data) {
$.each(data, function(i, e) {
if (e.Children.length>0) {
var ccd = e.Children;
delete e.Children;
finalData.push(e);
loopJson(ccd);
} else {
delete e.Children;
finalData.push(e);
}
});
}
console.log(finalData);