{"action":"opened","issue":{"url":"https://api.github.com/repos/bazaarvoice/jolt/issues/143","labels_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/143/labels{/name}","comments_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/143/comments","events_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/143/events","html_url":"https://github.com/bazaarvoice/jolt/issues/143","id":106688575,"number":143,"title":"Extract values and map to parent values in a one to many relationship","user":{"login":"joshsnelling","id":3750657,"avatar_url":"https://avatars.githubusercontent.com/u/3750657?v=3","gravatar_id":"","url":"https://api.github.com/users/joshsnelling","html_url":"https://github.com/joshsnelling","followers_url":"https://api.github.com/users/joshsnelling/followers","following_url":"https://api.github.com/users/joshsnelling/following{/other_user}","gists_url":"https://api.github.com/users/joshsnelling/gists{/gist_id}","starred_url":"https://api.github.com/users/joshsnelling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshsnelling/subscriptions","organizations_url":"https://api.github.com/users/joshsnelling/orgs","repos_url":"https://api.github.com/users/joshsnelling/repos","events_url":"https://api.github.com/users/joshsnelling/events{/privacy}","received_events_url":"https://api.github.com/users/joshsnelling/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-16T03:02:40Z","updated_at":"2015-09-16T03:02:40Z","closed_at":null,"body":"Hi,\r\n\r\nI've got the following input that I'm trying to restructure and I wonder if you might be able to help. The goal is to establish a unique entry in the output \"links\" array for each task to sub-task mapping identified in the input. \r\n\r\n````\r\n{\r\n  \"issues\" : [\r\n    {\r\n      \"id\" : \"1\",\r\n      \"key\" : \"ISSUE-1\",\r\n      \"fields\" : {\r\n        \"subtasks\" : [\r\n          {\r\n            \"id\" : \"2\"\r\n          },\r\n          {\r\n            \"id\" : \"3\"\r\n          }\r\n        ],\r\n        \"description\" : \"Issue #1\"\r\n      }\r\n    },\r\n    {\r\n      \"id\" : \"2\",\r\n      \"key\" : \"ISSUE-2\",\r\n      \"fields\" : {\r\n        \"description\" : \"Issue #2\"\r\n      }\r\n    },\r\n    {\r\n      \"id\" : \"3\",\r\n      \"key\" : \"ISSUE-3\",\r\n      \"fields\" : {\r\n        \"description\" : \"Issue #3\"\r\n      }\r\n    }\r\n  ]\r\n}\r\n````\r\n\r\nHere's the desired output:\r\n\r\n````\r\n{\r\n  \"links\" : [\r\n    {\r\n      \"name\" : \"sub-task-link\",\r\n      \"destinationId\" : \"2\",\r\n      \"sourceId\" : \"1\"\r\n    },\r\n    {\r\n      \"name\" : \"sub-task-link\",\r\n      \"destinationId\" : \"3\",\r\n      \"sourceId\" : \"1\"\r\n    }\r\n  ]\r\n}\r\n````\r\n\r\nSo far this is what I've come up with for the spec:\r\n\r\n````\r\n[\r\n\t{\r\n\t\t\"operation\": \"shift\",\r\n\t\t\"spec\": {\r\n\t\t\t\"issues\": {\r\n\t\t\t\t\"*\": {\r\n\t\t\t\t\t\"id\": \"links[&1].sourceId\",\r\n\t\t\t\t\t\"fields\": {\r\n\t\t\t\t\t\t\"subtasks\": {\r\n\t\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\t\"id\": \"links[#5].destinationId\"\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\t{\r\n\t\t\"operation\": \"default\",\r\n\t\t\"spec\": {\r\n\t\t\t\"links[]\": {\r\n\t\t\t\t\"*\": {\r\n\t\t\t\t\t\"name\": \"sub-task-link\"\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n]\r\n````\r\n\r\nThis almost works, but I end up getting out similar to the following:\r\n\r\n````\r\n{\r\n  \"links\" : [\r\n    {\r\n      \"destinationId\" : [\r\n        \"2\", \"3\"\r\n      ],\r\n      \"name\" : \"sub-task-link\",\r\n      \"sourceId\" : \"1\"\r\n    },\r\n    {\r\n      \"name\" : \"sub-task-link\",\r\n      \"sourceId\" : \"2\"\r\n    },\r\n    {\r\n      \"name\" : \"sub-task-link\",\r\n      \"sourceId\" : \"3\"\r\n    }\r\n  ]\r\n}\r\n````\r\n\r\nThe main issue I'm having is breaking apart each embedded sub-task ID into its own respective array entry. Any suggestions?\r\n\r\nThanks!"}}