将文本转换为json(Shell脚本)

时间:2017-10-18 11:27:38

标签: json text-files

在同一文件夹中的start处搜索data.txt文件,然后将data.txt转换为json并将其输出为data.json

在Linux shell脚本或任何其他脚本

我有一个文本文件data.txt

salary ; 2000 ; 14.0000 
salary ; 2800 ; 15.0000 
salary ; 2500 ; 16.0000 
salary ; 200 ; 17.0000 
salary ; 2500 ; 18.0000 
salary ; 2600 ; 198.0000 
salary ; 2700 ; 250.0000

我想在json文件data.json

中获取输出
[
{"Name":"salary", "amount":"2000","total":"14.000"},
{"Name":"salary", "amount":"2800","total":"15.000"},
{"Name":"salary", "amount":"2500","total":"16.000"},
{"Name":"salary", "amount":"200","total":"17.000"},
{"Name":"salary", "amount":"2500","total":"18.000"},
{"Name":"salary", "amount":"2600","total":"189.000"},
{"Name":"salary", "amount":"2700","total":"250.000"}
]

输出需要在.json文件中

0 个答案:

没有答案