Skip to content

Substation delete repeat key from array #211

Answered by jshlbrd
viraj-lunani asked this question in Q&A
Discussion options

You must be logged in to vote

@viraj-lunani There's a meta transform that can operate on values inside of a JSON array, you can build upon this:

local sub = import '../../../../../build/config/substation.libsonnet';

{
  transforms: [
    sub.tf.meta.for_each({
      object: { source_key: 'requestParameters.RandomField.PotentialOtherField.TagSpecification', target_key: 'requestParameters.RandomField.PotentialOtherField.TagSpecification' },
      transform: sub.tf.object.delete({ object: { source_key: 'tag'}})
    }),
    sub.tf.send.stdout(),
  ],
}

You can stack JSON paths to handle objects and arrays like this:

local sub = import '../../../../../build/config/substation.libsonnet';

{
  transforms: [
    sub.tf.obj.d…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by viraj-lunani
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants