I'd like to create a function in go which would be able to convert the text file below into a json output, however the format is kind of unique and only uses opening tags to mark the start of a new field in the the schema.
The input looks like this:
<$START-OF-DATA>
<$A>
<$B>Subtitle
<$C>Data1
<$C>Data2
<$E>Text Data
Sometimes in multiple lines
<$D>21:00:00 ET
<$D>22:00:00 ET
<$E>More Text Data
and I'd like to produce a JSON like this from it:
{
A:[],
B:["Subtitle"],
C:["Data1","Data2"]
D:["21:00:00 ET","22:00:00 ET"],
E:["Text Data
Sometimes in multiple lines","More Text Data"]
}
Is there any common practice to handle such parsing tasks? I have a general idea on how I'd go about it with RegExp but I fear that might be slow when processing a lot of files like this.
Thank you.