{"action":"created","issue":{"url":"https://api.github.com/repos/cweiske/jsonmapper/issues/59","repository_url":"https://api.github.com/repos/cweiske/jsonmapper","labels_url":"https://api.github.com/repos/cweiske/jsonmapper/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/cweiske/jsonmapper/issues/59/comments","events_url":"https://api.github.com/repos/cweiske/jsonmapper/issues/59/events","html_url":"https://github.com/cweiske/jsonmapper/issues/59","id":172514000,"number":59,"title":"How to map Map types?","user":{"login":"felixfbecker","id":10532611,"avatar_url":"https://avatars.githubusercontent.com/u/10532611?v=3","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-22T17:53:44Z","updated_at":"2016-10-10T07:39:29Z","closed_at":"2016-10-10T04:15:18Z","body":"How is it possible to map `Map` types, eg the JSON looks like this:\r\n```json\r\n{\r\n  \"changes\": {\r\n    \"file:///user/felix/my_file.php\": {\r\n      \"range\": {\r\n        \"start\": { \"line\": 1, \"character\": 1 },\r\n        \"end\": { \"line\": 1, \"character\": 2 }\r\n      },\r\n      \"newText\": \"whatever\"\r\n    },\r\n    \"file:///user/felix/my_file2.php\": {\r\n      \"range\": {\r\n        \"start\": { \"line\": 1, \"character\": 1 },\r\n        \"end\": { \"line\": 1, \"character\": 2 }\r\n      },\r\n      \"newText\": \"someNewText\"\r\n    }\r\n  }\r\n}\r\n```\r\nThe classes look like this: \r\n```php\r\nclass WorkspaceEdit\r\n{\r\n  /**\r\n    * Maps URIs to TextEdits.\r\n    *\r\n    * @var ?\r\n    */\r\n  public $changes;\r\n}\r\n\r\n/**\r\n * A textual edit applicable to a text document.\r\n */\r\nclass TextEdit\r\n{\r\n    /**\r\n     * The range of the text document to be manipulated. To insert\r\n     * text into a document create a range where start === end.\r\n     *\r\n     * @var Range\r\n     */\r\n    public $range;\r\n\r\n    /**\r\n     * The string to be inserted. For delete operations use an\r\n     * empty string.\r\n     *\r\n     * @var string\r\n     */\r\n    public $newText;\r\n}\r\n\r\nclass Range\r\n{\r\n     /**\r\n     * The range's start position.\r\n     *\r\n     * @var Position\r\n     */\r\n    public $start;\r\n\r\n    /**\r\n     * The range's end position.\r\n     *\r\n     * @var Position\r\n     */\r\n    public $end;\r\n}\r\n\r\nclass Position\r\n{\r\n    /**\r\n     * Line position in a document (zero-based).\r\n     *\r\n     * @var int\r\n     */\r\n    public $line;\r\n\r\n    /**\r\n     * Character offset on a line in a document (zero-based).\r\n     *\r\n     * @var int\r\n     */\r\n    public $character;\r\n}\r\n```\r\nNow, I see two possibilities for typing the `$changes` property:\r\n - type it as an associative array `TextEdit[]` - JsonMapper would have to convert the `stdClass` object to an associative array with `get_object_vars()` or by casting.\r\n - type it as a [`Map`](http://php.net/manual/en/class.ds-map.php) type (supports array syntax)\r\n - ~~type it as `mixed`~~\r\n  it will be an `stdClass` object and all the properties two, so not really a viable solution.\r\nWhich of these ways is supported by JsonMapper?\r\n\r\nMy usecase is implementing the Language Server Protocol in PHP to build a PHP Language Server. It builds on the JSONRPC protocol and I would like to use JsonMapper to map the requests recursively to the right classes because the JSON is heavily structured. But in the definition of `WorkspaceEdit` they use this map type: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#workspaceedit, which I don't know how to type."},"comment":{"url":"https://api.github.com/repos/cweiske/jsonmapper/issues/comments/252552468","html_url":"https://github.com/cweiske/jsonmapper/issues/59#issuecomment-252552468","issue_url":"https://api.github.com/repos/cweiske/jsonmapper/issues/59","id":252552468,"user":{"login":"felixfbecker","id":10532611,"avatar_url":"https://avatars.githubusercontent.com/u/10532611?v=3","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T07:39:29Z","updated_at":"2016-10-10T07:39:29Z","body":"Sorry I didn't have the chance to try this. Does the closed issue mean there is a test for this case or you can confirm associative arrays work?"}}
{"actor":{"display_login":"felixfbecker"}}