Skip to content

Commit

Permalink
merge: pull request #11 from SOTAEJI/fix/formatter
Browse files Browse the repository at this point in the history
fix: Initialize the parents array
  • Loading branch information
heung27 authored Oct 6, 2021
2 parents d7d3d9a + 9706ab9 commit 0b56e27
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 401-DataFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ module.exports = function(RED) {
};

let result = xmlParser.parse(xmlData, xmlOptions);
parents = [];
findAllParents(result, y_data);

parents.forEach((key) => {
Expand All @@ -137,7 +138,8 @@ module.exports = function(RED) {

function jsonParser(jsonData, y_data) {
try {
let result = jsonData;
let result = JSON.parse(jsonData);;
parents = [];
findAllParents(result, y_data);

parents.forEach((key) => {
Expand All @@ -158,8 +160,6 @@ module.exports = function(RED) {

function findAllParents(jsonObj, y_data) {
try {
parents = [];

if (jsonObj instanceof Object) {
const keys = Object.keys(jsonObj);
if (keys.includes(y_data)) {
Expand Down

0 comments on commit 0b56e27

Please sign in to comment.