Format table for JSON

0

Hello! I need to format the default Accel-PPP output in JSON, but I am not an experienced programmer and would like an efficient command to gain processing time. I found this link link. But the default output is different from the above link and is as follows:

  ifname  | username |    calling-sid    | rate-limit  
----------+----------+-------------------+-------------
 pppoe0   | joao     | EC:22:80:A2:5E:D5 | 10240/1024  
 pppoe2   | pedro    | C0:4A:00:88:E5:29 | 5120/1024   
 pppoe4   | maria    | B0:4E:26:B1:75:7D | 5120/1024     

And I would like it to look like this:

[ { "username":"joao", "data": { "ifname":"pppoe0", "calling-sid":"EC:22:80:A2:5E:D5", "rate-limit":"10240/1024" } },
{ "username":"pedro", "data": { "ifname":"pppoe2", "calling-sid":"C0:4A:00:88:E5:29", "rate-limit":"5120/1024"  } },
{ "username":"maria", "data": { "ifname":"pppoe4", "calling-sid":"B0:4E:26:B1:75:7D", "rate-limit":"5120/1024"  } } ]
    
asked by anonymous 17.05.2018 / 21:31

0 answers