前言
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,易于人阅读和编写,同时也易于机器解析和生成。本文提供一个真实的测试用例需求,设计逻辑类似Makefile,我以Bash处理JSON为例,Coding水平有限,请各位多多包涵哈,欢迎大家一起学习和挑战各种不同的语言来实现。
巧用jq处理JSON数据
Test Case
In data pipeline system and configuration management systems, it’s very common that you need execute a bunch of jobs which has dependencies with each other.
Write a program pipeline_runner to execute a list of shell scripts. The definition of those scripts and their dependencies are described in a JSON file. The program only takes in one argument which is the file path of JSON file that defines the jobs.
For example,
// jobs.json
{
"log0_compressed" : {
"commands": "curl http://websrv0/logs/access.log.gz > access0.log.gz",
"input": [],
"output": "access0.log.gz"
},
"log0" : {
"commands": "gunzip access0.log.gz",
"input": ["access0.log.gz"],
"output": "access0.log"
},
"log1_compressed": {
"commands": "curl http://websrv1/logs/access.log.gz > access1.log.gz&#