Skip to content

Several issues with flatten_preserve_lists #79

Description

@imbalu007

I found the following issues with flatten_preserve_lists

  1. flatten_preserve_lists({'K': ['abc', [1, 2, 3]]}, separator="+") results in the error re.error: nothing to repeat at position 1

  2. flatten_preserve_lists({'K': ['abc', [1, 2, 3]]}, separator="=+") (note that the 'separator' is '=+' and not '+' as in the previous case)

  • output: [{'K=+0=+1=+0=+1=+2': None, 'K=+0=+1=+0=+1': None, 'K=+0=+1=+0': None, 'K=+0': None, 'K': 'abc'}, {'K=+0=+1=+0=+1=+2': None, 'K=+0=+1=+0=+1': None, 'K=+0=+1=+0': None, 'K=+0': None, 'K': 1}, {'K=+0=+1=+0=+1=+2': None, 'K=+0=+1=+0=+1': None, 'K=+0=+1=+0': None, 'K=+0': None, 'K': 2}, {'K=+0=+1=+0=+1=+2': None, 'K=+0=+1=+0=+1': None, 'K=+0=+1=+0': None, 'K=+0': None, 'K': 3}]
  • expected: {'K': ['abc', [1, 2, 3]]} as the input is not nested
  1. flatten_preserve_lists({'K': ['abc', [[1, 2, 3]]]}, separator="=+")
  • output: [{'K=+0=+1=+0=+0=+1': None, 'K=+0=+1=+0=+0=+1=+2': None, 'K=+0=+1=+0=+0': None, 'K=+0': None, 'K': 'abc'}, {'K=+0=+1=+0=+0=+1': None, 'K=+0=+1=+0=+0=+1=+2': None, 'K=+0=+1=+0=+0': None, 'K=+0': None, 'K': [1, 2, 3]}]
  • expected: {'K': ['abc', [[1, 2, 3]]]} as the input is not nested
  1. flatten_preserve_lists({'K': ['abc', [1, 2, 3]]})
  • output: [{'K': 'abc'}, {'K': 1}, {'K': 2}, {'K': 3}]
  • expected: {'K': ['abc', [1, 2, 3]]} as the input is not nested
  1. flatten_preserve_lists({'K': ['abc', [[1, 2, 3]]]})
  • output: [{'K': 'abc'}, {'K': [1, 2, 3]}]
  • expected: {'K': ['abc', [1, 2, 3]]} as the input is not nested

I am working with the latest version of flatten_json, which is currently 0.1.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions