{"action":"created","issue":{"url":"https://api.github.com/repos/jacobwilliams/json-fortran/issues/208","repository_url":"https://api.github.com/repos/jacobwilliams/json-fortran","labels_url":"https://api.github.com/repos/jacobwilliams/json-fortran/issues/208/labels{/name}","comments_url":"https://api.github.com/repos/jacobwilliams/json-fortran/issues/208/comments","events_url":"https://api.github.com/repos/jacobwilliams/json-fortran/issues/208/events","html_url":"https://github.com/jacobwilliams/json-fortran/issues/208","id":159920651,"number":208,"title":"Adding \"default\" valur to json%get","user":{"login":"jacopo-chevallard","id":8123595,"avatar_url":"https://avatars.githubusercontent.com/u/8123595?v=3","gravatar_id":"","url":"https://api.github.com/users/jacopo-chevallard","html_url":"https://github.com/jacopo-chevallard","followers_url":"https://api.github.com/users/jacopo-chevallard/followers","following_url":"https://api.github.com/users/jacopo-chevallard/following{/other_user}","gists_url":"https://api.github.com/users/jacopo-chevallard/gists{/gist_id}","starred_url":"https://api.github.com/users/jacopo-chevallard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacopo-chevallard/subscriptions","organizations_url":"https://api.github.com/users/jacopo-chevallard/orgs","repos_url":"https://api.github.com/users/jacopo-chevallard/repos","events_url":"https://api.github.com/users/jacopo-chevallard/events{/privacy}","received_events_url":"https://api.github.com/users/jacopo-chevallard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-13T10:38:37Z","updated_at":"2016-06-13T15:36:53Z","closed_at":null,"body":"I was wondering if you think worth/interesting adding a ``default`` optional argument to the ``json%get`` methods, i.e. instead of having\r\n```fortran\r\n        call json%load_file(filename = 'test.txt')\r\n        call json%get('foo', i, found)\r\n        if (.not. found) i = default_foo\r\n```\r\nwe would have\r\n```fortran\r\n        call json%load_file(filename = 'test.txt')\r\n        call json%get('foo', i, default=default_foo)\r\n```\r\n\r\nWhere the optional ``found`` and ``default`` arguments should not be present at the same time.\r\n\r\nUsing the first option is completely fine (just 1 more line of code), but I think that the code would appear clearer by either using the ``found`` argument, which implies that one expects the ``foo`` key to be present in the JSON structure, and by using the ``default`` one, which relaxes this requirement."},"comment":{"url":"https://api.github.com/repos/jacobwilliams/json-fortran/issues/comments/225618861","html_url":"https://github.com/jacobwilliams/json-fortran/issues/208#issuecomment-225618861","issue_url":"https://api.github.com/repos/jacobwilliams/json-fortran/issues/208","id":225618861,"user":{"login":"jacobwilliams","id":6483379,"avatar_url":"https://avatars.githubusercontent.com/u/6483379?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobwilliams","html_url":"https://github.com/jacobwilliams","followers_url":"https://api.github.com/users/jacobwilliams/followers","following_url":"https://api.github.com/users/jacobwilliams/following{/other_user}","gists_url":"https://api.github.com/users/jacobwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobwilliams/subscriptions","organizations_url":"https://api.github.com/users/jacobwilliams/orgs","repos_url":"https://api.github.com/users/jacobwilliams/repos","events_url":"https://api.github.com/users/jacobwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/jacobwilliams/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T15:36:53Z","updated_at":"2016-06-13T15:36:53Z","body":"Interesting. Yes, this could be added. I would think to allow both `found` and `default` at the same time, since you still might want to know if it was there or not."}}
{"actor":{"display_login":"jacobwilliams"}}