{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2064","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2064/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2064/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2064/events","html_url":"https://github.com/Microsoft/TypeScript/issues/2064","id":58069122,"number":2064,"title":"Consider annotations and compilation of .json files","user":{"login":"NoelAbrahams","id":1106823,"avatar_url":"https://avatars.githubusercontent.com/u/1106823?v=3","gravatar_id":"","url":"https://api.github.com/users/NoelAbrahams","html_url":"https://github.com/NoelAbrahams","followers_url":"https://api.github.com/users/NoelAbrahams/followers","following_url":"https://api.github.com/users/NoelAbrahams/following{/other_user}","gists_url":"https://api.github.com/users/NoelAbrahams/gists{/gist_id}","starred_url":"https://api.github.com/users/NoelAbrahams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NoelAbrahams/subscriptions","organizations_url":"https://api.github.com/users/NoelAbrahams/orgs","repos_url":"https://api.github.com/users/NoelAbrahams/repos","events_url":"https://api.github.com/users/NoelAbrahams/events{/privacy}","received_events_url":"https://api.github.com/users/NoelAbrahams/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Needs%20Proposal","name":"Needs Proposal","color":"556b75"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"assignees":[{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false}],"milestone":null,"comments":16,"created_at":"2015-02-18T13:44:02Z","updated_at":"2016-09-26T17:58:42Z","closed_at":null,"body":"**Motivation**\r\n\r\nThe shape of JSON stored in files can be validated using [JSON schema](http://json-schema.org/). However, JSON schema cannot be used to ensure the stored JSON corresponds to a specific TypeScript interface.\r\n\r\nUnderstandably, most JSON tends to be stored in databases. However, there are many cases where small documents are stored on the file system in order to permit quick editing. Two common examples are config and resource files. The JSON in these files is loaded at runtime and accessed by JavaScript code, thereby necessitating they correspond to specific TypeScript interfaces.\r\n\r\nWe have a small but significant use case for this scenario.\r\n\r\n**Proposal**\r\n\r\nInterface declarations file `user.d.ts` \r\n\r\n```TypeScript\r\ndeclare module user {\r\n\r\n     interface Address {\r\n           house: number;\r\n           street: string;\r\n    }\r\n\r\n    interface User  {\r\n          name: string;\r\n          address:Address;\r\n          age: number;\r\n    }\r\n}\r\n```\r\n\r\nTypeScript JSON file `user.json.ts`\r\n\r\n```typescript\r\n/// <reference path=\"user.d.ts\" />\r\nuser.User: {            <----------- Annotation\r\n   \"name\": \"Joe Bloggs\", /*Comment*/    // Permit comments\r\n   \"address\": {\r\n\t   \"house\": \"1\", // Error: Number expected\r\n\t   street: \"London\"  // Error: Names must be quoted\r\n    },\r\n   \"age\": 55     // Error: Missing comma\r\n   \t\"id\": 101 // Error: Invalid property\r\n}\r\n```\r\n\r\nCompiled output (after errors are corrected): File `user.json`\r\n\r\n```typescript \r\n{\r\n   \"name\": \"Joe Bloggs\",\r\n   \"address\": {\r\n\t   \"house\": 1\r\n\t   \"street\": \"London\"\r\n    },\r\n   \"age\": 55\t\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/249646757","html_url":"https://github.com/Microsoft/TypeScript/issues/2064#issuecomment-249646757","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2064","id":249646757,"user":{"login":"NoelAbrahams","id":1106823,"avatar_url":"https://avatars.githubusercontent.com/u/1106823?v=3","gravatar_id":"","url":"https://api.github.com/users/NoelAbrahams","html_url":"https://github.com/NoelAbrahams","followers_url":"https://api.github.com/users/NoelAbrahams/followers","following_url":"https://api.github.com/users/NoelAbrahams/following{/other_user}","gists_url":"https://api.github.com/users/NoelAbrahams/gists{/gist_id}","starred_url":"https://api.github.com/users/NoelAbrahams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NoelAbrahams/subscriptions","organizations_url":"https://api.github.com/users/NoelAbrahams/orgs","repos_url":"https://api.github.com/users/NoelAbrahams/repos","events_url":"https://api.github.com/users/NoelAbrahams/events{/privacy}","received_events_url":"https://api.github.com/users/NoelAbrahams/received_events","type":"User","site_admin":false},"created_at":"2016-09-26T17:58:42Z","updated_at":"2016-09-26T17:58:42Z","body":"Hi, guys, is this on the radar?"}}
{"actor":{"display_login":"NoelAbrahams"}}