Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elements are lost from arrays of arrays #35

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

alexc155
Copy link
Contributor

If a GEDCOM contains arrays of arrays of elements, then the lowest layer elements are lost from the JSON.

This can be demonstrated with:

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

Expected:

{
 "Individuals": [
  {
   "Id": "@I1@",
   "Fullname": "John /Doe/",
   "Occupation": [
    {
     "Value": "Scholar",
     "Source": {
      "Name": "School Book"
     }
    },
    {
     "Value": "Soldier",
     "Source": [
      {
       "Name": "Army records"
      },
      {
       "Name": "Government records",
       "Text": "Page number: 2140",
       "Reference": {
        "Value": "http://URL.com/95105046",
        "Type": "URL"
       }
      }
     ]
    }
   ]
  }
 ]
}

Actual:

{
 "Individuals": [
  {
   "Id": "@I1@",
   "Fullname": "John /Doe/",
   "Occupation": [
    {
     "Value": "Scholar",
     "Source": {
      "Name": "School Book"
     }
    },
    {
     "Value": "Soldier",
     "Source": [
      {
       "Name": "Army records"
      },
      {
       "Name": "Government records"
      }
     ]
    }
   ]
  }
 ]
}

Notice the TEXT and REFN elements are lost.

The problem occurs in result.ts because only the lowest level of an array is considered when settings all sub-objects and building partPath to get the existing values.

The fix is to correctly set partPath to include which element in an array to try to get.

@alexc155 alexc155 changed the title FIX: Elements are lost from arrays of arrays Elements are lost from arrays of arrays Feb 28, 2024
@Jisco
Copy link
Owner

Jisco commented Feb 29, 2024

Hi, thank you. I will look into this too in a few days 👍 👍

@Jisco
Copy link
Owner

Jisco commented Mar 9, 2024

Yes, this seems to be right... thank you 👍

@Jisco Jisco merged commit 67aed88 into Jisco:master Mar 9, 2024
@alexc155 alexc155 deleted the lost-sub-elements branch March 11, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants