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

Have split_key still be present in the record #7

Open
justchris1 opened this issue Jun 24, 2021 · 0 comments
Open

Have split_key still be present in the record #7

justchris1 opened this issue Jun 24, 2021 · 0 comments

Comments

@justchris1
Copy link

First - thanks for this module. It has been quite useful.

I was wondering if there was an option for when the record was split, if the original record field could be preserved? To be more specific, I have a record that looks like this:

{
    "key1": "data1",
    "key2": "data2",
    "key3": {
        "key4": "data4",
        "key5": "data5"
    },
    "items": [ 
                {
                  "key6": "data6",
                  "key7": "data7"
                }, 
                {
                  "key8": "data8",
                  "key9": "data9",
                  "key10": "data10"
                }
            ],
    "key11": "data11"
}

A few notes: The elements inside the 'items' key are dictionaries, and do not neccessarily have the same keys (or even number of keys) inside them. They may or may not be overlap in the keys between dictionaries. In this example, they do not, but there is nothing stopping 'key6' also being present in the key8-10 dictionary with the same or different value than 'data6'.

I am trying to split_key on 'items'. If I do so, then I think this is the result (with keep_other_key true):

{
    "key1": "data1",
    "key2": "data2",
    "key3": {
        "key4": "data4",
        "key5": "data5"
    },
   "key6": "data6",
   "key7": "data7",
    "key11": "data11"
},
{
    "key1": "data1",
    "key2": "data2",
    "key3": {
        "key4": "data4",
        "key5": "data5"
    },
     "key8": "data8",
     "key9": "data9",
     "key10": "data10",
    "key11": "data11"
}

However, it totally removed all reference to 'items'. Ideally, I would just swap that to a dictionary (which now only has one 'entry'), like so:

{
    "key1": "data1",
    "key2": "data2",
    "key3": {
        "key4": "data4",
        "key5": "data5"
    },
    "items": {
                  "key6": "data6",
                  "key7": "data7"
                }, 
    "key11": "data11"
},
{
    "key1": "data1",
    "key2": "data2",
    "key3": {
        "key4": "data4",
        "key5": "data5"
    },
    "items": {
                  "key8": "data8",
                  "key9": "data9",
                  "key10": "data10"
                },
    "key11": "data11"
}

Do you have any suggestion on how I might do that or some way of enhancing this module to support that?

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

No branches or pull requests

1 participant