thedevsaddam / gojsonq

A simple Go package to Query over JSON/YAML/XML/CSV Data
https://github.com/thedevsaddam/gojsonq/wiki
MIT License
2.17k stars 140 forks source link

Support for unselect #71

Closed gboor closed 4 years ago

gboor commented 4 years ago

I have an array of JSON objects which all contain a few common keys and then a whole bunch of keys that are different. I want to select a subset of this array that drops a single common key.

The only way to do that right now is to use a select or only with all the possible keys the object can contain minus the one I want to drop. It would be nice to support something like "unselect" or "drop" where I can drop a specific key from the result while keeping the rest.

thedevsaddam commented 4 years ago

@gboor You can use the Select method to keep the field you want in the result. Which eventually drops the fields you want to disappear.

Kvaz1r commented 4 years ago

@thedevsaddam , that's not the point. Here proposed to add new function for case where Select doesn't fit good. Function Select is "keep_if" operation but sometimes is also useful "drop_if" operation.