Created
October 3, 2025 18:07
-
-
Save ConstBur/e2a9ef2ff30a9db5da4c92d34c0f68c5 to your computer and use it in GitHub Desktop.
Jq stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| jq -s 'add | group_by(.id) | [.[] | reduce . as $item ({ "id": "", "prop1": "", "iface": "" }; { "id": $item.[0].id, "prop1": $item.[0].prop1, "iface": $item.[1].prop2[0].ifa | |
| ce })]' obj1.json obj2.json > output.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "id1", | |
| "prop1": "test1", | |
| "to_remove": "remove me" | |
| }, | |
| { | |
| "id": "id2", | |
| "prop1": "test2", | |
| "to_remove": "remove me" | |
| }, | |
| { | |
| "id": "id3", | |
| "prop1": "test3", | |
| "to_remove": "remove me" | |
| } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "id1", | |
| "prop2": [ | |
| { | |
| "iface": "value1" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "id2", | |
| "prop2": [ | |
| { | |
| "iface": "value2" | |
| } | |
| ] | |
| }, | |
| { | |
| "id": "id3", | |
| "prop2": [ | |
| { | |
| "iface": "value3" | |
| } | |
| ] | |
| } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "id1", | |
| "prop1": "test1", | |
| "iface": "value1" | |
| }, | |
| { | |
| "id": "id2", | |
| "prop1": "test2", | |
| "iface": "value2" | |
| }, | |
| { | |
| "id": "id3", | |
| "prop1": "test3", | |
| "iface": "value3" | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment