機械翻訳について

サポートされているjq機能

Rapid Adapter Builderプラットフォームでは、このトピックで指定されているjq機能のサブセットがサポートされています。

jq関数の完全なリストは、「jqマニュアル」を参照してください。 jq 1.6に適用可能な「制限事項」を参照してください。

Rapid Adapter Builderプラットフォームは、次のjq機能をサポートしています:

基本フィルタ

  • .
  • .foo, .foo.bar
  • .[<string>], .[2], .[10:15]
  • .[]
  • .[]?
  • ,
  • ¿

タイプと値

  • アレイの構築 - []
  • オブジェクト - {}

組込みの演算子および関数

  • 追加 - +
  • 減算 - -
  • 乗算、除算、モジュロ - *, /, および%
  • length
  • keys, keys_unsorted
  • has(key)
  • in
  • path(path_expression)
  • del(path_expression)
  • to_entries, from_entries, with_entries
  • select(boolean_expression)
  • 配列、オブジェクト、反復可能、ブール、数値、法線、有限、文字列、null、値、スカラー
  • empty
  • error(message)
  • map(x), map_values(x)
  • paths, paths(node_filter), leaf_paths
  • add
  • any, any(condition), any(generator; condition)
  • all, all(condition), all(generator; condition)
  • flatten, flatten(depth)
  • range(upto), range(from;upto) range(from;upto;by)
  • floor
  • sqrt
  • tonumber
  • tostring
  • type
  • infinite、nan、isinfinite、isan、isfinite、isnormal
  • sort, sort_by(path_expression)
  • group_by(path_expression)
  • min, max, min_by(path_exp), max_by(path_exp)
  • unique, unique_by(path_exp)
  • reverse
  • contains(element)
  • indices(s)
  • index(s), rindex(s)
  • inside
  • startswith(str)
  • endswith(str)
  • combinations, combinations(n)
  • ltrimstr(str)
  • rtrimstr(str)
  • explode
  • implode
  • split
  • join(str)
  • ascii_downcase, ascii_upcase
  • recurse(f), recurse, recurse(f; condition), recurse_down
  • walk
  • ..
  • setpath、delpaths、getpath
  • utf8bytelength
  • transpose
  • 文字列補間 - \(foo)
  • JSONへの変換
  • 文字列の書式設定およびエスケープ
  • 日付

条件と比較

  • ==, !=
  • if-then-else
  • >, >=, <=, <
  • and/or/not
  • 代替演算子 - //
  • try-catch

正規表現(PCRE)

  • test(val), test(regex; flags)
  • match(val), match(regex; flags)
  • capture(val), capture(regex; flags)
  • scan(regex), scan(regex; flags)
  • split(regex; flags)
  • splits(regex), splits(regex; flags)
  • sub(regex; tostring) sub(regex; string; flags)

高度な機能

  • 変数

    演算子の優先順位を確認するには、カッコを使用します。

  • 関数の定義

    重複した関数名は避けてください。

  • リデュース
  • limit(n; exp)
  • first(expr), last(expr), nth(n; expr)
  • first, last, nth(n)
  • foreach
  • 帰納

    最大5レベル。

  • ジェネレータとイテレータ

Math

代入

  • =
  • |=
  • +=, -=, *=, /=, %=, //=
  • 複雑な割り当て

jq機能の使用方法を示すサンプル・コード

to_entries

例:

入力json アダプタ定義ドキュメントの式 出力json
{
"potato": true,
"broccoli": false
}
{
"uri": "http://surveyUrl.com",
"method": "POST",
"body": "${ {vegetableFeedback : .input|to_entries } }"
}
{
...
  "body" : {
    "vegetableFeedback" : [ {
      "key" : "potato",
      "value" : true
    }, {
      "key" : "broccoli",
      "value" : false
    } ]
  }
}

from_entries

例:

入力json アダプタ定義ドキュメントの式 出力json
{
"vegetables": [
{
"key": "potato",
"value": true
 },
{
"name": "broccoli",
"value": false
 }
]
}
"standardFromEntriesArguments": {
"uri": "http://surveyUrl.com",
"method": "POST",
"body": "${ {vegetableFeedback : .input.vegetables|from_entries } }"
}
{
...
  "body" : {
    "vegetableFeedback" :  {
      "potato" : true,
     "broccoli" : false
    } 
  }

@csv

この関数は、配列をCSV形式に変換します。

例:

入力json アダプタ定義ドキュメントの式 出力json
{
"vegetables": [
{
"veggieName": "potato",
"like": true
 },
{
"veggieName": "broccoli",
"like": false
 }
]
}
{
"arguments": {


"body": "${ .input.vegetables[]|[.veggieName, .like]|@csv  }"

}
}
{

...

  "body" :

"

\"potato\",true
\"broccoli\",false

"

  }

}

@tsv

この関数は、配列をタブ区切り値に変換します。

例:

入力json アダプタ定義ドキュメントの式 出力json
{
"vegetables": [
{
"veggieName": "potato",
"like": true
 },
{
"veggieName": "broccoli",
"like": false
 }
]
}
{
"arguments": {
"body": "${ .input.vegetables[]|[.veggieName, .like]|@tsv  }"
}
}
{
...
  "body" :
"
potato    true
broccoli    false
"
  }
}

@base64

例:

入力json アダプタ定義ドキュメントの式 出力json
{
"username":"a","password":"b"
}
{
"arguments": {
"body": "${ .username + ":"+ .password|@base64 }"
}
}
{

...

  "body" : "YTpi" //(base64 encoded a:b)

}

@base64d

例:

入力json アダプタ定義ドキュメントの式 出力json

{ "username":"a","password":"b" }

{ "arguments": { "body": "${ .username + ":"+ .password|@base64|@base64d }" } }

{ ... "body" : "a:b" //(base64 encoded a:b) }