Beginner here, I hope you can direct me to right path. Using curl, I get some statistical information from my TP-Link router. I put that information to a text file. However, I need this info in JSON format so that I can use it elsewhere. The format of the text file is like this:[0,0,0,0,0,0]0enable=1interval=10action=0[1,0,0,0,0,0]1ipAddress=3232235848macAddress=EC:0E:C4:4F:XX:XXtotalPkts=201totalBytes=22914currPkts=0currBytes=0currIcmp=0currUdp=0currSyn=0currIcmpMax=0currUdpMax=15currSynMax=0[2,0,0,0,0,0]1ipAddress=3232235829macAddress=00:16:E8:22:XX:XXtotalPkts=972totalBytes=98730currPkts=0currBytes=0currIcmp=0currUdp=0currSyn=0currIcmpMax=0currUdpMax=14currSynMax=4[3,0,0,0,0,0]1ipAddress=3232235842macAddress=70:14:A6:8B:XX:XXtotalPkts=154566totalBytes=15116490currPkts=0currBytes=0currIcmp=0currUdp=0currSyn=0currIcmpMax=9currUdpMax=58currSynMax=60I need a JSON something like:{ipAddress : 3232235848,macAddress : EC:0E:C4:4F:XX:XX,totalPkts : 201,totalBytes : 22914,currPkts : 0,currBytes : 0,currIcmp : 0,currUdp : 0,currSyn : 0,currIcmpMax : 0,currUdpMax : 15,currSynMax : 0}{ipAddress : 3232235829, ...Could you show me the most efficient way of doing this? I prefer a bash script if it is possible? Tried putting | jq -R -s -c 'split(\n)' to the end of curl command but then it looks like:    {ipAddress=3232235848,macAddress=EC:0E:C4:4F:XX:XX ...
Convert text file to JSON
text processing;json
perl -lne 'BEGIN{*1 = sub {print q<{>, join(,\n, splice @A, 0, @A), q<}>}}   next if $. == 1;   /^\[(?:\d+,?)+\]\d+$/ and &1,next;   push @A, join q/ : /, map qq/$_/, split /=/;   eof && &1;' yourfile