Nested JSON
#438
Replies: 2 comments 2 replies
-
I had it working in dasel V1 (see dasel V1 expression below), but dasel V2 has defeated me.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Something like this? [
{
"ASO": "ASO-2178",
"Amount": 6300,
"CustomerName": "The Power Company"
},
{
"ASO": "ASO-2197",
"Amount": 20100,
"CustomerName": "Acme Ltd"
},
{
"ASO": "ASO-2319",
"Amount": 4500,
"CustomerName": "The Power Company"
}
] |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am having trouble extracting fields from a Json file with three levels of nesting and converting them to CSV.
I would like the output to look like this:
Customer, Type of Work, ASO, Type of Work-Subtype, Amount
Acme Ltd, Managed Services, ASO-2197, Configuration, 20,100.00
The Power Company, Consultancy, ASO-2178, New, 6,300.00
The first three records of the JSON file are as follows.
{"expand":"schidema,names", "startAt":0, "maxResults":100, "total":92, "issues":[ { "expand":"operations,versionedRepresentations,editmeta,changelog,customfield_10134.properties,renderedFields", "id":"17084", "self":"https://automation-consultants.atlassian.net/rest/api/2/issue/17084", "key":"ASO-2178", "fields":{ "customfield_10140": [{"self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10532", "value":"New", "id":"10532"}], "customfield_10139":{ "self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10528", "value":"Consultancy", "id":"10528"}, "customfield_10111":6300.0, "customfield_10134":{ "id":417, "value":"The Power Company"}}}, { "expand":"operations,versionedRepresentations,editmeta,changelog,customfield_10134.properties,renderedFields", "id":"17149", "self":"https://automation-consultants.atlassian.net/rest/api/2/issue/17149", "key":"ASO-2197", "fields":{ "customfield_10140": [{"self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10536", "value":"Configuration", "id":"10536"}, {"self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10542", "value":"ITSM", "id":"10542"}, {"self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10533", "value":"Renewal", "id":"10533"}, {"self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10534", "value":"Upgrade", "id":"10534"}], "customfield_10139":{ "self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10529", "value":"Managed Services", "id":"10529"}, "customfield_10111":20100.0, "customfield_10134":{ "id":76,"value":"Acme Ltd"}}}, { "expand":"operations,versionedRepresentations,editmeta,changelog,customfield_10134.properties,renderedFields", "id":"17628", "self":"https://automation-consultants.atlassian.net/rest/api/2/issue/17628", "key":"ASO-2319", "fields":{ "customfield_10140": [{"self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10532", "value":"New", "id":"10532"}], "customfield_10139":{ "self":"https://automation-consultants.atlassian.net/rest/api/2/customFieldOption/10528", "value":"Consultancy", "id":"10528"}, "customfield_10111":4500.0, "customfield_10134":{ "id":417,"value":"The Power Company"}}},
I can get the ASO and Amount columns with the following dasel command.
dasel -f JQL_out0 -r json -w csv 'issues.all().mapOf(ASO,key,Amount,fields.customfield_10111).merge()'
But I can't get any deeper into the JSON than this, and I can't extract the Customer name., ,for example. Any help to fix this would be much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions