question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It would be cool, if the library would allow serializing arrays as scalar values like:

input:

[{
    name: "Jack",
    age: 39,
    friends: [{ name: "Oliver", age: 40 }, { name: "Harry", age: 50 }],
}, {
    name: "Thomas",
    age: 40,
    friends: [{ name: "Harry", age: 35 }]
}]

output:

name,age,friends.0.name,friends.0.age,friends.1.name,friends.1.age
Jack,39,Oliver,40,Harry,50
Thomas,40,Harry,35

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
knownasilyacommented, Jul 11, 2019

I think we could do a backward compatible version, maybe even keeping flatten as-is and adding flattenArrays option. My rational is that this seems like a fringe case, since we are just now seeing a request for it and there probably won’t be additional options to flatten of the same nature, since there is no other complex data structures that you’d see in json. If we do see a reason for making it one option, we could do that in a future major version, e.g. v5.

0reactions
kuchtacommented, Jul 11, 2019

I like flatten = true|'objects'|'arrays'|false more, but I understand that I would introduce backward incompatible change, which is probably OK for major version change. Do you mean, that true would flatten both objects and arrays, right? I just can’t see use case for flatten = 'arrays'. Maybe ```flatten = true|‘evenArrays’|false would be better since it could be backward compatible when true means flatten just objects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array.prototype.flat() - JavaScript - MDN Web Docs
The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
Read more >
JavaScript: Flatten an array using different methods - Flexiple
Flattening an array is a process of reducing the dimensionality of an array. In other words, it a process of reducing the number...
Read more >
Merge/flatten an array of arrays - javascript - Stack Overflow
flat () method which you could use to flatten the arrays. It is compatible with most environments, although it is only available in...
Read more >
7 Ways to Flatten Arrays in JavaScript | by Zachary Lee
Array flattening is to convert multi-layer nested arrays to only one layer. To explain it in code, it would be [1, [2, [3,...
Read more >
How to Flatten a Nested Javascript Array | by Cynthia Okoliezeh
To flatten an array means to reduce the dimensionality of an array. In simpler terms, it means reducing a multidimensional array to a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found