Parsing an Objects.xml file using JQ¶
You first need to convert your objects.xml file to json, objects.json
This one selects “datasources” from objects:
jq '[ .objects.object[][][] | select ( .["@id"] == "datasources")[] ]' objects.json
- Selects datasource “SnapTBSP” from objects::
- jq ‘[ .objects.object[][] |
select ( .[“@id”] == “datasources”)[] | select (.[“@id”] == “SnapTBSP”) ]’ objects.json
Select datapoints[][] from SnapTBSP ds:
jq '[ .objects.object[][][] | select ( .["@id"] == "datasources")[] | select (.["@id"] == "SnapTBSP")[] | select (.["@id"] == "datapoints")[][] ]' objects.json
List just the @id labels from the datapoints of SnapTBSP ds:
jq '[ .objects.object[][][] | select ( .["@id"] == "datasources")[] | select (.["@id"] == "SnapTBSP")[] | select (.["@id"] == "datapoints")[][] | {"@id"} ]' objects.json
Select datapoints[][] from DB2DataSource class:
jq '[ .objects.object[][][] | select ( .["@id"] == "datasources")[] | select (.["@class"] == "DB2DataSource")[] | select (.["@id"] == "datapoints")[][] | {"@id"} ]' objects.json