Skip to content

Commit

Permalink
FIX: Elements are lost from arrays of arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
alexc155 committed Feb 28, 2024
1 parent 5b9f1f3 commit 8d43c48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions examples/singlePerson.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
0 @I1@ INDI
1 NAME John /Doe/
1 OCCU Scholar
2 SOUR School Book
1 OCCU Soldier
2 SOUR Army records
2 SOUR Government records
3 TEXT Page number: 2140
3 REFN http://URL.com/95105046
4 TYPE URL
0 TRLR
12 changes: 11 additions & 1 deletion src/ToJSON/processing/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,17 @@ export function CreateMainObject(objects: ParsingObject[]): MainObject {
return;
}

partPath.push(property);
partPath.push(property);

const parentPath = dropRight(partPath);
const parentObj = objectPath.get(result, parentPath);

if (parentPath.length > 0 && objectPath.has(result, parentPath) && isArray(parentObj)) {
partPath = parentPath;
partPath.push(`${parentObj.length - 1}`);
partPath.push(property);
}

if (!objectPath.has(result, partPath)) {
objectPath.set(result, partPath, {});
return;
Expand Down

0 comments on commit 8d43c48

Please sign in to comment.