Skip to content

Support unknown object keys #15

@MikeCarbone

Description

@MikeCarbone

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions