bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.54k stars 328 forks source link

How to do JSON conversion with special characters #1148

Closed CloudWise-Lukemiao closed 2 years ago

CloudWise-Lukemiao commented 2 years ago

Hello everyone, I want to [{"timestamp":1,"root.dd4.aa":14.5},{"timestamp":1,"root.dd4.bb":14.5}] convert jolt into [{"timestamp": 1, "root.dd4.aa1": 14.5}, {"timestamp": 1, "root.dd4.bb1": 14.5}]。This is a simple example of what I should do.

ouxuyong commented 2 years ago

@CloudWise-Lukemiao This spec of mine can achieve the effect you want, I hope it can help you. In addition, there is a jolt tutorial project, welcome to communicate and discuss jolt-universe.

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "timestamp": "[#2].timestamp",
        "root.dd4.aa": "[#2].root\\.dd4\\.aa1",
        "root.dd4.bb": "[#2].root\\.dd4\\.bb1"
      }
    }
  }
]
CloudWise-Lukemiao commented 2 years ago

@CloudWise-Lukemiao This spec of mine can achieve the effect you want, I hope it can help you. In addition, there is a jolt tutorial project, welcome to communicate and discuss jolt-universe.

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "timestamp": "[#2].timestamp",
        "root.dd4.aa": "[#2].root\\.dd4\\.aa1",
        "root.dd4.bb": "[#2].root\\.dd4\\.bb1"
      }
    }
  }
]

@CloudWise-Lukemiao This spec of mine can achieve the effect you want, I hope it can help you. In addition, there is a jolt tutorial project, welcome to communicate and discuss jolt-universe.

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "timestamp": "[#2].timestamp",
        "root.dd4.aa": "[#2].root\\.dd4\\.aa1",
        "root.dd4.bb": "[#2].root\\.dd4\\.bb1"
      }
    }
  }
]

Thanks for your help