Sign inSign up

weevenetwork/data-unflattener

By weevenetwork

Updated over 3 years ago

Image
0

505

weevenetwork/data-unflattener repository overview

Data Unflattener

NameData Unflattener
Versionv1.0.0
GitHubweeve-modules/data-unflattener
AuthorsJakub Grzelak

Description

Restore your flattened data to its previous nested form. Use the following symbols for indicating parentness in your data labels, i.e. if parentness is / then data {'location/city': 'Berlin'} will be restored to {'location': {'city': 'Berlin'}}. If you expect your restored data to contain a list of JSON objects then select "Search for Lists" option. It will treat numbers in data labels as indicators of list indexing in the restored data, i.e. {'location/0/city': 'Berlin'} will be restored to {'location': [ {'city': 'Berlin'} ]} (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 data labels, i.e. if delimiter is / then data {'location/city': 'Berlin'} will be restored to {'location': {'city': 'Berlin'}}.
Search for ListsSEARCH_FOR_LISTSstringIf true then numbers in data labels will indicate list indexing in the restored data, i.e. {'location/0/city': 'Berlin'} will be restored 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/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/email/1/address": "[email protected]",
    "employees/1/email/1/type": "private",
    "employees/1/age": 28,
    "employees/2/name": "John",
    "employees/2/email": "[email protected]",
    "employees/2/age/year": 1990,
    "employees/2/age/month": "January",
    "employees/2/age/day": 1,
    "employees/3/name": "Bob",
    "employees/3/email": "[email protected]",
    "employees/3/age": 41
}
  • array of JSON body objects, example:
[
    {
        "location/city": "Berlin",
        "location/country": "Germany"
    },
    {
        "device/name": "RaspberryPi",
        "device/id": "dasc4d4a"
    }
]

Output

If DELIMITER = / and SEARCH_FOR_LISTS = True then output of 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"
                },
                {
                    "address": "[email protected]",
                    "type": "private"
                }
            ],
            "age": 28
        },
        {
            "name": "John",
            "email": "[email protected]",
            "age": {
                "year": 1990,
                "month": "January",
                "day": 1
            }
        },
        {
            "name": "Bob",
            "email": "[email protected]",
            "age": 41
        }
    ]
}
  • array of JSON body objects, example:
[
    {
        "location": {
            "city": "Berlin",
            "country": "Germany"
        }
    },
    {
        "device": {
            "name": "RaspberryPi",
            "id": "dasc4d4a"
        }
    }
]

Tag summary

Content type

Image

Digest

sha256:d2d22e58d

Size

48.4 MB

Last updated

over 3 years ago

docker pull weevenetwork/data-unflattener:v1.0.1