Sign inSign up

weevenetwork/data-flattener

By weevenetwork

Updated over 3 years ago

Image
0

502

weevenetwork/data-flattener repository overview

Data Flattener

NameData Flattener
Versionv1.0.0
GitHubweeve-modules/data-flattener
AuthorsJakub Grzelak

Description

Flatten your nested data. Use the following symbols for indicating parentness in your nested data, i.e. if parentness is / then data {'location': {'city': 'Berlin'}} will be flattened to {'location/city': 'Berlin'}. If data contains a list of JSON objects then each object will be given a numeric index in the new label in the flattened output (see a list example in Output)

Environment Variables

Module Specific

The following module configurations can be provided in a data service designer section on weeve platform:

NameEnvironment VariablestypeDescription
DelimiterDELIMITERstringSymbol for indicating parentness delimiter in your nested data, i.e. if delimiter is / then data {'location': {'city': 'Berlin'}} will be flattened to {'location/city': 'Berlin'}
Set by the weeve Agent on the edge-node

Other features required for establishing the inter-container communication between modules in a data service are set by weeve agent.

Environment VariablestypeDescription
MODULE_NAMEstringName of the module
MODULE_TYPEstringType of the module (Input, Processing, Output)
EGRESS_URLSstringHTTP ReST endpoints for the next module
INGRESS_HOSTstringHost to which data will be received
INGRESS_PORTstringPort to which data will be received

Dependencies

bottle
requests

Input

Input to this module is:

  • JSON body single object, example:
{
    "employees": [
        {
            "name": {
                "first-name": "Ram",
                "family-name": "Blue"
            },
            "email": "[email protected]",
            "age": 23
        },
        {
            "name": {
                "first-name": "Shyam",
                "family-name": "Red"
            },
            "email": [
                {
                    "address": "[email protected]",
                    "type": "business"
                }
            ],
            "age": 28
        }
    ]
}

  • array of JSON body objects, example:
[
    {
        "location": {
            "city": "Berlin",
            "country": "Germany"
        }
    },
    {
        "device": {
            "name": "RaspberryPi",
            "id": "dasc4d4a"
        }
    }
]

Output

If DELIMITER = / then output of this module is:

  • JSON body single object, example:
{
    "employees/0/name/first-name": "Ram",
    "employees/0/name/family-name": "Blue",
    "employees/0/email": "[email protected]",
    "employees/0/age": 23,
    "employees/1/name/first-name": "Shyam",
    "employees/1/name/family-name": "Red",
    "employees/1/email/0/address": "[email protected]",
    "employees/1/email/0/type": "business",
    "employees/1/age": 28,
}

  • array of JSON body objects, example:
[
    {
        "location/city": "Berlin",
        "location/country": "Germany"
    },
    {
        "device/name": "RaspberryPi",
        "device/id": "dasc4d4a"
    }
]

Tag summary

Content type

Image

Digest

sha256:507ba072e

Size

48.4 MB

Last updated

over 3 years ago

docker pull weevenetwork/data-flattener:v1.0.1