Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent data loss on missing order keys #122

Open
gschier opened this issue Jun 4, 2020 · 0 comments
Open

Prevent data loss on missing order keys #122

gschier opened this issue Jun 4, 2020 · 0 comments

Comments

@gschier
Copy link

gschier commented Jun 4, 2020

Here is an example of how data loss can occur on missing keys. It would be nice if the "failure" condition favored keeping data instead of skipping it 馃檪

const obj = {
  users: [
    { name: 'Tom', id: 1 },
    { name: 'Jane', id: 2 },
  ],
};

const order = {
  '$': ['users'],
  '$.users.0': ['id', 'name'],
};

const result = orderedJSON.order(obj, order);

// result is missing the second user
//
// {
//   users: [{
//     id: 1,
//     name: 'Tom',
//   }],
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant