When working with my application, I am loading text data from a text file:
The contents of this txt file are as follows:
console.log(myData):
### Comment 1
## Comment two
dataone=1
datatwo=2
## Comment N
dataThree=3
I am looking to convert this data to JSON by following these steps:
- Remove all comment lines (beginning with #) and empty lines
- Replace all = with :
- Add quotes to the data attributes to make it look like this
- Wrap everything inside { }
The resulting JSON would appear as follows:
{
"dataone":"1"
"datatwo":"2"
"dataThree":"3"
}
Is there a quick way to achieve this formatting?