{"action":"created","issue":{"url":"https://api.github.com/repos/bazaarvoice/jolt/issues/137","labels_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/137/comments","events_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/137/events","html_url":"https://github.com/bazaarvoice/jolt/issues/137","id":103329504,"number":137,"title":"Repeat values ","user":{"login":"rsdb","id":6884430,"avatar_url":"https://avatars.githubusercontent.com/u/6884430?v=3","gravatar_id":"","url":"https://api.github.com/users/rsdb","html_url":"https://github.com/rsdb","followers_url":"https://api.github.com/users/rsdb/followers","following_url":"https://api.github.com/users/rsdb/following{/other_user}","gists_url":"https://api.github.com/users/rsdb/gists{/gist_id}","starred_url":"https://api.github.com/users/rsdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsdb/subscriptions","organizations_url":"https://api.github.com/users/rsdb/orgs","repos_url":"https://api.github.com/users/rsdb/repos","events_url":"https://api.github.com/users/rsdb/events{/privacy}","received_events_url":"https://api.github.com/users/rsdb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-26T17:51:49Z","updated_at":"2015-09-09T18:54:20Z","closed_at":null,"body":"Is there away to repeat a value in the output? I have the following data that I would like to flatten.\r\n\r\nInput:\r\n```\r\n{\r\n\t\"metrics\": [\r\n\t\t{\r\n\t\t\t\"metricName\": \"bytesin\",\r\n\t\t\t\"instances\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"instance\": \"someserver.domain.com\",\r\n\t\t\t\t\t\"times\": [\r\n\t\t\t\t\t\t1430919180,\r\n\t\t\t\t\t\t1430919240,\r\n\t\t\t\t\t\t1430919300,\r\n\t\t\t\t\t\t1430919360\r\n\t\t\t\t\t],\r\n\t\t\t\t\t\"values\": [\r\n\t\t\t\t\t\t3423560.5,\r\n\t\t\t\t\t\t3350273.25,\r\n\t\t\t\t\t\t3357055.5,\r\n\t\t\t\t\t\t3402069.25\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}\r\n```\r\n\r\nSchema:\r\n```\r\n[\r\n\t{\r\n\t\t\"operation\": \"shift\",\r\n\t\t\"spec\": {\r\n\t\t\t\"metrics\": {\r\n\t\t\t\t\"0\": {\r\n\t\t\t\t\t\"metricName\": {\r\n\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\"$\": \"data.headers[2]\"\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"instances\": {\r\n\t\t\t\t\t\t\"0\": {\r\n\t\t\t\t\t\t\t\"instance\": {\r\n\t\t\t\t\t\t\t\t\"$\": \"data.headers[0]\",\r\n\t\t\t\t\t\t\t\t\"@\": \"data.rows.[].[]\"\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\"times\": {\r\n\t\t\t\t\t\t\t\t\"$\": \"data.headers[1]\",\r\n\t\t\t\t\t\t\t\t\"@\": \"data.rows\"\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\"values\": {\r\n\t\t\t\t\t\t\t\t\"@\": \"data.rows\"\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\t\"*\": {\r\n\t\t\t\t\t\"metricName\": {\r\n\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\"$\": \"data.headers\"\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"instances\": {\r\n\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\"values\": {\r\n\t\t\t\t\t\t\t\t\"@\": \"data.rows\"\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]\r\n```\r\n\r\nOutput:\r\n```\r\n{\r\n  \"data\" : {\r\n    \"headers\" : [ \"instance\", \"times\", \"bytesin\" ],\r\n    \"rows\" : [ [ \"someserver.domain.com\" ], [ 1430919180, 1430919240, 1430919300, 1430919360 ], [ 3423560.5, 3350273.25, 3357055.5, 3402069.25 ] ]\r\n  }\r\n}\r\n```\r\n\r\nI would like \"someserver.domain.com\" to be repeated, 3 times in this case, so that the first nested array in \"rows\" has 4 elements like the others. Is that possible?"},"comment":{"url":"https://api.github.com/repos/bazaarvoice/jolt/issues/comments/139007323","html_url":"https://github.com/bazaarvoice/jolt/issues/137#issuecomment-139007323","issue_url":"https://api.github.com/repos/bazaarvoice/jolt/issues/137","id":139007323,"user":{"login":"milosimpson","id":1203207,"avatar_url":"https://avatars.githubusercontent.com/u/1203207?v=3","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":"2015-09-09T18:54:20Z","updated_at":"2015-09-09T18:54:20Z","body":"This spec, will maintain the input order of the metric.   It is weirder looking, but relies on more explicit Shiftr operator precedence to maintain the order.\r\n\r\n\r\n```javacript\r\n[\r\n\t{\r\n\t\t\"operation\": \"shift\",\r\n\t\t\"spec\": {\r\n\t\t\t\"metrics\": {\r\n\t\t\t\t\"0\": {\r\n\t\t\t\t\t\"metricName\": \"metricNamesOrder\",\r\n\t\t\t\t\t\"instances\": {\r\n\t\t\t\t\t\t\"0\": {\r\n\t\t\t\t\t\t\t\"times\": {\r\n\t\t\t\t\t\t\t\t\"@\": \"times\",\r\n\t\t\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\t\t\"@(2,instance)\": \"instance\"\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\"values\": \"@(3,metricName)\"\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\"times\": {\r\n\t\t\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\t\t\"@\": \"times\",\r\n\t\t\t\t\t\t\t\t\t\"@(2,instance)\": \"instance\"\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\"values\": {\r\n\t\t\t\t\t\t\t\t\"*\": \"@(4,metricName)\"\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\t\"*\": {\r\n\t\t\t\t\t\"metricName\": \"metricNamesOrder\",\r\n\t\t\t\t\t\"instances\": {\r\n\t\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\t\"values\": {\r\n\t\t\t\t\t\t\t\t\"*\": \"@(4,metricName)\"\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\": \"shift\",\r\n\t\t\"spec\": {\r\n\t\t\t\"#times\": \"data.headers[0]\",\r\n\t\t\t\"#instance\": \"data.headers[1]\",\r\n\t\t\t\"@(times)\": \"data.rows[0]\",\r\n\t\t\t\"@(instance)\": \"data.rows[1]\",\r\n\t\t\t\"metricNamesOrder\": {\r\n\t\t\t\t\"*\": {\r\n\t\t\t\t\t\"*\": {\r\n\t\t\t\t\t\t\"$\": \"data.headers\",\r\n\t\t\t\t\t\t\"@(4,&)\": \"data.rows\"\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]\r\n```"}}