diff --git a/examples/singlePerson.ged b/examples/singlePerson.ged new file mode 100644 index 0000000..beefb3c --- /dev/null +++ b/examples/singlePerson.ged @@ -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 \ No newline at end of file diff --git a/src/ToJSON/processing/result.ts b/src/ToJSON/processing/result.ts index 224ecad..e3bc720 100644 --- a/src/ToJSON/processing/result.ts +++ b/src/ToJSON/processing/result.ts @@ -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;