My (huge) input file has many entries , what I want to extract is structured like that:
{"vulnerabilities": [ {"parentAlert": {"affectedVersions": [ {"answers": [ {"willBeFixed": true,"fixedInPackage": "2.31.0" } ],"productName": "LDEwS" }, {"answers": [ {"willBeFixed": true,"fixedInPackage": "2.32.0" }, {"willBeFixed": false,"fixedInPackage": "3.0.0" } ],"productName": "Foo" } ] } } ]}I want to extract the info of that type:
{"willBeFixed": true,"fixedInPackage": "2.31.0","productName": "LDEwS"}{"willBeFixed": true,"fixedInPackage": "2.32.0","productName": "Foo"}{"willBeFixed": false,"fixedInPackage": "3.0.0","productName": "Foo"}I can't find the proper jp command. Can you please help to find out ?
The following command seems to work fine (for one field):
.vulnerabilities[] |{ willBeFixed: .parentAlert.affectedVersions[].answers[].willBeFixed}{"willBeFixed": true}{"willBeFixed": true}{"willBeFixed": false}But not the following ones.
.vulnerabilities[] |{ willBeFixed: .parentAlert.affectedVersions[].answers[].willBeFixed, fixedInPackage: .parentAlert.affectedVersions[].answers[].fixedInPackage}.vulnerabilities[] |{ willBeFixed: .parentAlert.affectedVersions[].answers[].willBeFixed, fixedInPackage: .parentAlert.affectedVersions[].answers[].fixedInPackage, productName: .parentAlert.affectedVersions[].productName}It gives all possible combinations between the 2 fields in the first one and between the 3 fields in the second one.
{"willBeFixed": true,"fixedInPackage": "2.31.0"}{"willBeFixed": true,"fixedInPackage": "2.32.0"}{"willBeFixed": true,"fixedInPackage": "3.0.0"}{"willBeFixed": true,"fixedInPackage": "2.31.0"}...