Skip to content

Trying to flatten deeply nested lists fails #477

@tillywoodfield

Description

@tillywoodfield

Trying to flatten more than a 2-level nested list fails.

Version: 0.27.0

Steps to reproduce

Create example.json file containing a 3-level nested list:

{
  "main": [
    {
      "nested_list": [
        [
          ["a", "b"],
          ["c", "d"]
        ]
      ]
    }
  ]
}

Try to flatten:

flatten-tool flatten example.json

Result:

<class 'collections.OrderedDict'>
<class 'list'>
[['a', 'b'], ['c', 'd']]
'list' object has no attribute 'items'

Possible solutions

  1. Flatten the whole list into a string, e.g. "[[[""a"",""b""],[""c"",""d""]]]", this is what flatterer does.
  2. As a minimum, fail gracefully and ignore the list, allowing the rest of the process to continue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions