Ask HN: Best way to turn plain text tab-indented list into JSON?
I have a list of unknown depth in plain text, where the levels are represented by tabs.
Something like this:
item 1
item 1.1
item 1.2
item 2
item 2.1
item 2.2
item 2.2.1
item 2.2.2
item 3
What is the most efficient way to turn this into a JSON array (ideally in JavaScript)?Of course, I could go line by line, have a currIndentation variable and create an array, but I'm wondering if there is a better way.