{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Configuration/issues/115","labels_url":"https://api.github.com/repos/aspnet/Configuration/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Configuration/issues/115/comments","events_url":"https://api.github.com/repos/aspnet/Configuration/issues/115/events","html_url":"https://github.com/aspnet/Configuration/issues/115","id":42819830,"number":115,"title":"Support arrays as values in JSON configuration source","user":{"login":"ChengTian","id":1383883,"avatar_url":"https://avatars.githubusercontent.com/u/1383883?v=3","gravatar_id":"","url":"https://api.github.com/users/ChengTian","html_url":"https://github.com/ChengTian","followers_url":"https://api.github.com/users/ChengTian/followers","following_url":"https://api.github.com/users/ChengTian/following{/other_user}","gists_url":"https://api.github.com/users/ChengTian/gists{/gist_id}","starred_url":"https://api.github.com/users/ChengTian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChengTian/subscriptions","organizations_url":"https://api.github.com/users/ChengTian/orgs","repos_url":"https://api.github.com/users/ChengTian/repos","events_url":"https://api.github.com/users/ChengTian/events{/privacy}","received_events_url":"https://api.github.com/users/ChengTian/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/Configuration/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/aspnet/Configuration/labels/needs%20design","name":"needs design","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"victorhurdugaci","id":5921642,"avatar_url":"https://avatars.githubusercontent.com/u/5921642?v=3","gravatar_id":"","url":"https://api.github.com/users/victorhurdugaci","html_url":"https://github.com/victorhurdugaci","followers_url":"https://api.github.com/users/victorhurdugaci/followers","following_url":"https://api.github.com/users/victorhurdugaci/following{/other_user}","gists_url":"https://api.github.com/users/victorhurdugaci/gists{/gist_id}","starred_url":"https://api.github.com/users/victorhurdugaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorhurdugaci/subscriptions","organizations_url":"https://api.github.com/users/victorhurdugaci/orgs","repos_url":"https://api.github.com/users/victorhurdugaci/repos","events_url":"https://api.github.com/users/victorhurdugaci/events{/privacy}","received_events_url":"https://api.github.com/users/victorhurdugaci/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/Configuration/milestones/10","html_url":"https://github.com/aspnet/Configuration/milestones/1.0.0-beta5","labels_url":"https://api.github.com/repos/aspnet/Configuration/milestones/10/labels","id":1029693,"number":10,"title":"1.0.0-beta5","description":"","creator":{"login":"glennc","id":234688,"avatar_url":"https://avatars.githubusercontent.com/u/234688?v=3","gravatar_id":"","url":"https://api.github.com/users/glennc","html_url":"https://github.com/glennc","followers_url":"https://api.github.com/users/glennc/followers","following_url":"https://api.github.com/users/glennc/following{/other_user}","gists_url":"https://api.github.com/users/glennc/gists{/gist_id}","starred_url":"https://api.github.com/users/glennc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennc/subscriptions","organizations_url":"https://api.github.com/users/glennc/orgs","repos_url":"https://api.github.com/users/glennc/repos","events_url":"https://api.github.com/users/glennc/events{/privacy}","received_events_url":"https://api.github.com/users/glennc/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":1,"state":"open","created_at":"2015-03-19T17:22:22Z","updated_at":"2015-04-10T23:17:48Z","due_on":null,"closed_at":null},"comments":17,"created_at":"2014-09-15T21:15:14Z","updated_at":"2015-04-21T23:38:49Z","closed_at":null,"body":"Need to figure out a proper representation of arrays when they used as values. Also need to figure out the corresponding things in xml and ini files."},"comment":{"url":"https://api.github.com/repos/aspnet/Configuration/issues/comments/94975165","html_url":"https://github.com/aspnet/Configuration/issues/115#issuecomment-94975165","issue_url":"https://api.github.com/repos/aspnet/Configuration/issues/115","id":94975165,"user":{"login":"victorhurdugaci","id":5921642,"avatar_url":"https://avatars.githubusercontent.com/u/5921642?v=3","gravatar_id":"","url":"https://api.github.com/users/victorhurdugaci","html_url":"https://github.com/victorhurdugaci","followers_url":"https://api.github.com/users/victorhurdugaci/followers","following_url":"https://api.github.com/users/victorhurdugaci/following{/other_user}","gists_url":"https://api.github.com/users/victorhurdugaci/gists{/gist_id}","starred_url":"https://api.github.com/users/victorhurdugaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorhurdugaci/subscriptions","organizations_url":"https://api.github.com/users/victorhurdugaci/orgs","repos_url":"https://api.github.com/users/victorhurdugaci/repos","events_url":"https://api.github.com/users/victorhurdugaci/events{/privacy}","received_events_url":"https://api.github.com/users/victorhurdugaci/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T23:38:49Z","updated_at":"2015-04-21T23:38:49Z","body":"Below is a summary of the discussion and the spec.\r\n\r\nTL;DR;\r\n----\r\n\r\n- Only json supports array. The magic will happen at options level, not config.\r\n- Sorting in integers first, everything after\r\n- Override happens at item level. Same index => overwrite\r\n\r\nHow it looks like\r\n---\r\n\r\nAll the configurations below are equivalent:\r\n\r\n**json**\r\n\r\n```\r\n\"ip\": [\r\n    \"1.2.3.4\",\r\n    \"3.4.5.6\",\r\n    \"2.5.643.4\"\r\n]\r\n```\r\nwhich is actually syntactic sugar for\r\n```\r\n\"ip\": {\r\n    \"0\": \"1.2.3.4\",\r\n    \"1\": \"3.4.5.6\",\r\n    \"2\": \"2.5.43.4\"\r\n}\r\n```\r\n\r\nFor json arrays, the indices are implied to be 0, 1, 2, ...\r\n\r\n**environment variables**\r\n\r\n```\r\nSET ip:0 = 1.2.3.4\r\nSET ip:1 = 3.4.5.6\r\nSET ip:2 =  2.5.43.4\r\n```\r\n\r\n**xml**\r\n\r\n```\r\n<ip name=\"0\">1.2.3.4</ip>\r\n<ip name=\"1\">3.4.5.6</ip>\r\n<ip name=\"2\">2.5.43.4</ip>\r\n```\r\n\r\n**ini**\r\n\r\n```\r\n[addresses]\r\nip:0 = 1.2.3.4\r\nip:1 = 3.4.5.6\r\nip:2 =  2.5.43.4\r\n```\r\n\r\n**command line arguments**\r\n\r\n```\r\n--ip:0 = 1.2.3.4 --ip:1 = 3.4.5.6 --ip:2 =  2.5.43.4\r\n```\r\n\r\nUsage\r\n---\r\n\r\n```\r\nConfiguration config = new Configuration(<sources>);\r\n            \r\nvar subkeys = config.GetSubKeys(\"ip\");\r\n\r\nforeach(var ip in subkeys)\r\n{\r\n    // Might change ToString to be the same as Get(null)\r\n    Console.WriteLine(ip.Value.Get(null));\r\n}\r\n```\r\n\r\nOverwrite and concat rules\r\n---\r\n\r\n**Overwrite**\r\n\r\nThe last one wins at index level\r\n\r\nIf this comes first\r\n```\r\n\"ip\": [\r\n    \"1.2.3.4\",\r\n    \"3.4.5.6\",\r\n    \"2.5.643.4\"\r\n]\r\n```\r\n\r\nand this second\r\n```\r\n<ip name=\"1\">0.0.0.0</ip>\r\n```\r\n\r\nthe result is:\r\n\r\n```\r\n1.2.3.4\r\n0.0.0.0\r\n2.5.643.4\r\n```\r\n\r\nBecause \"3.4.5.6\" gets index \"1\" and gets overwritten by the value from xml (which has name = \"1\")\r\n\r\n**Concat/append**\r\n\r\nIf you want to append, use named indices to avoid conflicts\r\n\r\nIf this comes first\r\n```\r\n\"ip\": [\r\n    \"1.2.3.4\",\r\n    \"3.4.5.6\",\r\n    \"2.5.643.4\"\r\n]\r\n```\r\n\r\nand this second\r\n```\r\n<ip name=\"john\">0.0.0.0</ip>\r\n```\r\n\r\nthe result is\r\n\r\n\r\n```\r\n1.2.3.4\r\n3.4.5.6\r\n2.5.643.4\r\n0.0.0.0\r\n```\r\n\r\n\r\nSorting\r\n---\r\n\r\n- Integer-only indices come first and are sorted numerically.\r\n- Everything else comes after sorted using the default string sort\r\n- For json arrays, the items are kept in the order in which they appear in the json file\r\n\r\nCaveats\r\n---\r\n\r\n```\r\n\"ip\": [\r\n    \"1.2.3.4\",\r\n    \"3.4.5.6\",\r\n    \"2.5.643.4\"\r\n]\r\n```\r\n\r\nand\r\n\r\n```\r\n\"ip\": \"0.0.0.0\"\r\n```\r\n\r\nare perfectly valid and the config system will read them differently. The second \"ip\" is not an array of one element.\r\n\r\n\r\nOptions\r\n---\r\n\r\nOptions will support model binding to arrays. Will be part of the same change and that's where we encourage everyone to consider arrays. Config will not have arrays as first class citizens."}}