如何在 JOLT 中执行 `@class`

How to do `@class` in JOLT

我正在使用 Java JOLT JSON 转换库,想知道如何吐出一个以 @class 为键的元素。由于“@”是通配符,它​​试图解释符号而不是将其输出为字符串。

我需要指定 java class 以便 jackson 正确映射。

我想做类似的事情:

"locations": {
                "*": {
                    "#location": "tempLocations[&1].riskItemType",
                    "#com.object.beans.element.Location": "tempLocations[&1].@class",`

所以它会吐出类似这样的东西:

{"@class": "com.object.beans.element.location"

来自json-ld-escaping在线示例:

Note in order to escape Shiftr special chars, you have to use two backslashes

示例:

[
  {
    "operation": "shift",
    "spec": {
      // In this example, we want to change some of the LHS keys in this Json document.
      // To accomplish this we escape the leading '@' chars both as spec matches (left hand side)
      //  and as output paths (right hand side).
      //
      // Note in order to escape Shiftr special chars, you have to use two backslashes,
      //  because Java.
      // Also, all other Shiftr special chars should be escapable: . @ $ & \ [  ]
      "\@context": {
        "name": "&1.Name",
        "ingredient": "&1.Inputs",
        "yield": "\@context.Makes",
        // pass the rest thru
        "*": "&1.&"
      },
      "name": "Name",
      "ingredient": "Inputs",
      "yield": "Makes",
      "*": "&"
    }
  }
]