{"action":"created","issue":{"url":"https://api.github.com/repos/bazaarvoice/jolt/issues/450","repository_url":"https://api.github.com/repos/bazaarvoice/jolt","labels_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/450/labels{/name}","comments_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/450/comments","events_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/450/events","html_url":"https://github.com/bazaarvoice/jolt/issues/450","id":269190364,"number":450,"title":"Need guidance on a complex transformation of array to heirarchical structure","user":{"login":"shreevats","id":508505,"avatar_url":"https://avatars1.githubusercontent.com/u/508505?v=4","gravatar_id":"","url":"https://api.github.com/users/shreevats","html_url":"https://github.com/shreevats","followers_url":"https://api.github.com/users/shreevats/followers","following_url":"https://api.github.com/users/shreevats/following{/other_user}","gists_url":"https://api.github.com/users/shreevats/gists{/gist_id}","starred_url":"https://api.github.com/users/shreevats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shreevats/subscriptions","organizations_url":"https://api.github.com/users/shreevats/orgs","repos_url":"https://api.github.com/users/shreevats/repos","events_url":"https://api.github.com/users/shreevats/events{/privacy}","received_events_url":"https://api.github.com/users/shreevats/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-27T18:07:49Z","updated_at":"2017-11-03T14:54:18Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI'm new to JOLT and I am ramping up using the javadoc and the demo site. However, I'm not able to perform the following transformation:\r\n\r\n**Input sample**:\r\n``` \r\n[\r\n  {\r\n    \"dataMap\": {\r\n      \"ID\": \"F000123\",\r\n      \"COUNTRY\": \"ca\",\r\n      \"CODE\": \"ABC\",\r\n      \"BASE\": \"rtip\",\r\n      \"PROPERTY\": \"property_1\",\r\n      \"VALUE\": \"1\"\r\n    }\r\n  },\r\n  {\r\n    \"dataMap\": {\r\n      \"ID\": \"B000ENUCRE\",\r\n      \"COUNTRY\": \"ca\",\r\n      \"CODE\": \"ABC\",\r\n      \"BASE\": \"rtip\",\r\n      \"PROPERTY\": \"property_2\",\r\n      \"VALUE\": \"true\"\r\n    }\r\n  },\r\n  {\r\n    \"dataMap\": {\r\n      \"ID\": \"B000ENUCRE\",\r\n      \"COUNTRY\": \"ca\",\r\n      \"CODE\": \"ABC\",\r\n      \"BASE\": \"rtip\",\r\n      \"PROPERTY\": \"property_3\",\r\n      \"VALUE\": \"good\"\r\n    }\r\n  },\r\n  {\r\n    \"dataMap\": {\r\n      \"ID\": \"B000ENUCRE\",\r\n      \"COUNTRY\": \"ca\",\r\n      \"CODE\": \"ABC\",\r\n      \"BASE\": \"BAR\",\r\n      \"PROPERTY\": \"property_1\",\r\n      \"VALUE\": \"1\"\r\n    }\r\n  },\r\n  {\r\n    \"dataMap\": {\r\n      \"ID\": \"B000ENUCRE\",\r\n      \"COUNTRY\": \"ca\",\r\n      \"CODE\": \"ABC\",\r\n      \"BASE\": \"BAR\",\r\n      \"PROPERTY\": \"property_6\",\r\n      \"VALUE\": \"1\"\r\n    }\r\n  }\r\n]\r\n```\r\n**Output expected**:\r\n```\r\n{\r\n  \"AG_ID\": \"F000123-CA\", //concatination of ID and COUNTRY\r\n  \"Scope\": \"ABC\", // code\r\n  \"ModelNumber\": 1, // default\r\n  \"VersionNumber\": 1, // default\r\n  \"PropertiesByBase\": [\r\n    {\r\n      \"base\": \"rtip\",\r\n      \"properties\": {\r\n        \"property_1\": \"1\",\r\n        \"property_2\": \"true\",\r\n        \"property_3\": \"good\"\r\n      }\r\n    },\r\n    {\r\n      \"base\": \"BAR\",\r\n      \"properties\": {\r\n        \"property_1\": \"1\",\r\n        \"property_6\": \"1\"\r\n      }\r\n    }\r\n  ]\r\n}\r\n```\r\nKey challenges:\r\n- Parse through the list and fetch some top level 'values'\r\n- I need to aggregate the properties from the same base and put each aggregation into a list\r\n\r\nCan someone take a look?"},"comment":{"url":"https://api.github.com/repos/bazaarvoice/jolt/issues/comments/341726487","html_url":"https://github.com/bazaarvoice/jolt/issues/450#issuecomment-341726487","issue_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/450","id":341726487,"user":{"login":"milosimpson","id":1203207,"avatar_url":"https://avatars0.githubusercontent.com/u/1203207?v=4","gravatar_id":"","url":"https://api.github.com/users/milosimpson","html_url":"https://github.com/milosimpson","followers_url":"https://api.github.com/users/milosimpson/followers","following_url":"https://api.github.com/users/milosimpson/following{/other_user}","gists_url":"https://api.github.com/users/milosimpson/gists{/gist_id}","starred_url":"https://api.github.com/users/milosimpson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milosimpson/subscriptions","organizations_url":"https://api.github.com/users/milosimpson/orgs","repos_url":"https://api.github.com/users/milosimpson/repos","events_url":"https://api.github.com/users/milosimpson/events{/privacy}","received_events_url":"https://api.github.com/users/milosimpson/received_events","type":"User","site_admin":false},"created_at":"2017-11-03T14:54:18Z","updated_at":"2017-11-03T14:54:18Z","author_association":"MEMBER","body":"Spec\r\n\r\n```\r\n[\r\n  {\r\n    \"operation\": \"modify-default-beta\",\r\n    \"spec\": {\r\n      \"[0]\": {\r\n        \"dataMap\": {\r\n          // build an AG_ID is the first entry\r\n          // will use this as the overall AG_ID\r\n          \"AG_ID\": \"=concat(@(1,ID),'-',@(1,COUNTRY))\"\r\n        }\r\n      }\r\n    }\r\n  },\r\n  {\r\n    \"operation\": \"shift\",\r\n    \"spec\": {\r\n      \"0\": {\r\n        \"dataMap\": {\r\n          \"AG_ID\": \"AG_ID\",\r\n          \"CODE\": \"scope\",\r\n          \"BASE\": {\r\n            \"*\": {\r\n              \"@2\": \"basesPivot.&1[]\"\r\n            }\r\n          }\r\n        }\r\n      },\r\n      \"*\": {\r\n        \"dataMap\": {\r\n          \"BASE\": {\r\n            \"*\": {\r\n              \"@2\": \"basesPivot.&1[]\"\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  },\r\n  {\r\n    \"operation\": \"shift\",\r\n    \"spec\": {\r\n      // passthru\r\n      \"AG_ID|scope\": \"&\",\r\n      \"basesPivot\": {\r\n        \"*\": { // rtip or BAR\r\n          \"$\": \"PropertiesByBase[#2].base\",\r\n          \"*\": {\r\n            \"@VALUE\": \"PropertiesByBase[#3].properties.@PROPERTY\"\r\n          }\r\n        }\r\n      }\r\n    }\r\n  },\r\n  {\r\n    \"operation\": \"modify-overwrite-beta\",\r\n    \"spec\": {\r\n      \"AG_ID\": \"=toUpper\",\r\n      \"ModelNumber\": 1, // default\r\n      \"VersionNumber\": 1 // default\r\n    }\r\n  }\r\n]\r\n```\r\n\r\nOn the demo site, run each step by itself to see / figure out / understand what it is doing."}}
{"actor":{"display_login":"milosimpson"}}