Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

JQ delete property based other property value

$
0
0

I'm trying to write a JQ filter allowing me to selectively filter object properties based on other of it's values.

For example, given following input

{"object1": {"Type": "Type1","Properties": {"Property1": "blablabla","Property2": [    {"Key": "Name","Value": "xxx"    },    {"Key": "Surname","Value": "yyy"    }  ],"Property3": "xxx" }},"object2": {"Type": "Type2","Properties": {"Property1": "blablabla","Property2": [    {"Key": "Name","Value": "xxx"    },    {"Key": "Surname","Value": "yyy"    }  ],"Property3": "xxx"  } }}

I would like to construct a filter, that based upon the object type, say "Type2", deletes or clears a property of that object, say Property2.The resulting output would then be:

{"object1": {"Type": "Type1","Properties": {"Property1": "blablabla","Property2": [    {"Key": "Name","Value": "xxx"    },    {"Key": "Surname","Value": "yyy"    }  ],"Property3": "xxx" }},"object2": {"Type": "Type2","Properties": {"Property1": "blablabla","Property3": "xxx"  } }}

Any help greatly appreciated. Thanks in advance.


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>