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

Support unknown object keys #15

Open
MikeCarbone opened this issue Oct 9, 2023 · 0 comments
Open

Support unknown object keys #15

MikeCarbone opened this issue Oct 9, 2023 · 0 comments

Comments

@MikeCarbone
Copy link
Member

MikeCarbone commented Oct 9, 2023

Sometimes in a data source, the key will be unknown. For example, the name.nativeName field in the data from this API has a a key of a language. That key is an abbreviation for a language, and we cant anticipate what that key will be.

How can we handle this? We still want the data to have structure, as in, we know the keys within that field are official and common, so it's not entirely unstructured, and it'd be a shame if we lose all structure within because of this. We need a generic here.

Maybe:

{
  name: {
    schema: {
       type: "object",
       object_schema: {
          nativeName: {
            schema: {
              type: "object",
              object_schema: {
                "<<generic>>": {
                  schema: {
                    type: "object",                    
                    field_name_enum: languagesArr
                    object_schema: {
                      official: {
                        schema: {
                          type: "string"
                        }
                      },
                      common: {
                        schema: {
                          type: "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
       }
    }
  }
}

This is a possible mapping. We do two novel things here:

  1. <<generic>> - use our variables pattern to symbolize a dynamic field here
  2. field_name_enum - a new schema property to let us know the possible options for the field's name
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