Skip to content

Unflatten method doesn't work with "toString" key #127

Description

@yukienomiya

Problem

The unflatten method doesn't work with a key named toString.

For example, starting with this object:

{
  "p5": {
    "y": "The y component of the vector",
    "toString": {
      "returns": "String: "
    }
  }
}

Then flatten it:

{
  'p5/y': 'The y component of the vector',
  'p5/toString/returns': 'String: '
}

And then unflatten it:

{
  "p5": {
    "y": "The y component of the vector"
  }
}

The toString key disappears.

Workaround

I ended up adding a prefix to all the keys while flattening the object (with the transformKey option), and then removing it after unflattening it again. To remove the prefix I used the map-obj library to map all the key and values from the original object to a new one, where the keys were substrings of the original ones.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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