内置函数 mapValues 作用:将map类型的value抽取为数组 输入参数: 参数 类型 说明 示例 内置函数第一个参数 map对象 注意是通过访问输入或者输出数据变量引用的方式得到的传参 不支持直接传参map,例如mapValues({"k1":"v1", "k2":"v2"} ) plaintext { "input": { "k1": "v1", "k2": "v2" } } "{ mapValues($.input) }" 输出示例: plaintext ["v1", "v2"] mapToJSONString 作用:将map对象的数据转换为json格式的字符串 输入参数: 参数 类型 说明 示例 内置函数第一个参数 map对象 注意是通过访问输入或者输出数据变量引用的方式得到的传参 不支持直接传参map,例如mapToJSONString({"k1":"v1", "k2":"v2"} ) plaintext { "input": { "k1": "v1", "k2": "v2" } } "{ mapToJSONString($.input) }" 输出示例: plaintext "{"input": {"k1": "v1","k2": "v2"}}" jsonStringToMap 作用:对目标字符串进行正则匹配 输入参数: 参数 类型 说明 示例 内置函数第一个参数 字符串 JSON格式字符 jsonStringToMap("{"input": {"k1": "v1","k2": "v2"}}") 输出示例: plaintext {"input": {"k1": "v1","k2": "v2"}} jq 作用:对map对象基于jq语法进行数据过滤处理 输入参数: 参数 类型 说明 示例 内置函数第一个参数 map对象 注意是通过访问输入或者输出数据变量引用的方式得到的传参 不支持直接传参map,例如jq({"k1":"v1", "k2":"v2"}, "jq语法处理语句" ) plaintext { "books": [ { "author": "Nigel Rees", "category": "reference", "price": 8.95, "title": "Sayings of the Century" }, { "author": "Evelyn Waugh", "category": "reference", "price": 12.99, "title": "Sword of Honour" }, { "author": "Herman Melville", "category": "fiction", "isbn": "0553213113", "price": 8.99, "title": "Moby Dick" }, { "author": "J. R. R. Tolkien", "category": "fiction", "isbn": "0395193958", "price": 22.99, "title": "The Lord of the Rings" } ] } "{ jq($, '.books[] select((.price > 12) and (.category ! "reference"))') } }" "{ jq($, '.books[] select(.price > 12)') }" 内置函数第二个参数 jq语法字符串 注意是通过访问输入或者输出数据变量引用的方式得到的传参 不支持直接传参map,例如jq({"k1":"v1", "k2":"v2"}, "jq语法处理语句" ) plaintext { "books": [ { "author": "Nigel Rees", "category": "reference", "price": 8.95, "title": "Sayings of the Century" }, { "author": "Evelyn Waugh", "category": "reference", "price": 12.99, "title": "Sword of Honour" }, { "author": "Herman Melville", "category": "fiction", "isbn": "0553213113", "price": 8.99, "title": "Moby Dick" }, { "author": "J. R. R. Tolkien", "category": "fiction", "isbn": "0395193958", "price": 22.99, "title": "The Lord of the Rings" } ] } "{ jq($, '.books[] select((.price > 12) and (.category ! "reference"))') } }" "{ jq($, '.books[] select(.price > 12)') }" 输出示例: plaintext {"author":"J. R. R. Tolkien","category":"fiction","isbn":"0395193958","price":22.99,"title":"The Lord of the Rings"} plaintext [{"author":"Evelyn Waugh","category":"reference","price":12.99,"title":"Sword of Honour"},{"author":"J. R. R. Tolkien","category":"fiction","isbn":"0395193958","price":22.99,"title":"The Lord of the Rings"}]