Substation delete repeat key from array #211
-
hey I have the following situation
it may also be the case that the
I want to delete the lowercase To be clear anytime there is a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@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.delete({ object: { source_key: 'requestParameters.RandomField.PotentialOtherField.TagSpecification.tag'}}),
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(),
],
} Your sample input isn't valid JSON, but the above was tested with this: {"requestParameters":{"RandomField":{"PotentialOtherField":{"TagSpecification":[{"tag":"value","Tag":[]},{"tag":"value","Tag":[]}]}}}}
{"requestParameters":{"RandomField":{"PotentialOtherField":{"TagSpecification":{"tag":"value","Tag":[]}}}}} |
Beta Was this translation helpful? Give feedback.
@viraj-lunani There's a meta transform that can operate on values inside of a JSON array, you can build upon this:
You can stack JSON paths to handle objects and arrays like this: