bazaarvoice / jolt

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

Why is the key obtained from "&2" not "rating" #1258

Open ddy123 opened 4 months ago

ddy123 commented 4 months ago

屏幕截图 2024-06-04 165252

The key obtained from "&1" is the "primary" and "quality" key

gbouget commented 4 months ago

Why is the key obtained from "&2" not "rating" #1258 Because the node is 3 levels above.

The key obtained from "&1" is the "primary" and "quality" key Are you sure?

[
  {
    "operation": "shift",
    "spec": {
      "rating": { // &3, three levels above
        "*": { // primary or quality (&2, two levels above)
          "*": { // value (&1, one level above)
            "$": "&3" // &3 starts here and moves up the tree nodes by two levels
          }
        }
      }
    }
  }
]
ddy123 commented 4 months ago

屏幕截图 2024-06-04 174328 The key obtained from "&1" is the "primary" and "quality" key Why are these two different

ddy123 commented 4 months ago

Why is the key obtained from "&2" not "rating" #1258 Because the node is 3 levels above.

The key obtained from "&1" is the "primary" and "quality" key Are you sure?

[
  {
    "operation": "shift",
    "spec": {
      "rating": { // &3, three levels above
        "*": { // primary or quality (&2, two levels above)
          "*": { // value (&1, one level above)
            "$": "&3" // &3 starts here and moves up the tree nodes by two levels
          }
        }
      }
    }
  }
]

Please look above

gbouget commented 4 months ago

image

ddy123 commented 4 months ago

thanks,I got it.The JSON tree is constructed by the ”spec“,not the "input". 屏幕截图 2024-06-04 214117

ddy123 commented 4 months ago

I still got it wrong. It's based on the current layer and iterating upwards