{"action":"created","issue":{"url":"https://api.github.com/repos/izumin5210/json-schema-parser/issues/1","labels_url":"https://api.github.com/repos/izumin5210/json-schema-parser/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/izumin5210/json-schema-parser/issues/1/comments","events_url":"https://api.github.com/repos/izumin5210/json-schema-parser/issues/1/events","html_url":"https://github.com/izumin5210/json-schema-parser/issues/1","id":90754790,"number":1,"title":"RangeError: Maximum call stack size exceeded","user":{"login":"Quramy","id":1262998,"avatar_url":"https://avatars.githubusercontent.com/u/1262998?v=3","gravatar_id":"","url":"https://api.github.com/users/Quramy","html_url":"https://github.com/Quramy","followers_url":"https://api.github.com/users/Quramy/followers","following_url":"https://api.github.com/users/Quramy/following{/other_user}","gists_url":"https://api.github.com/users/Quramy/gists{/gist_id}","starred_url":"https://api.github.com/users/Quramy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Quramy/subscriptions","organizations_url":"https://api.github.com/users/Quramy/orgs","repos_url":"https://api.github.com/users/Quramy/repos","events_url":"https://api.github.com/users/Quramy/events{/privacy}","received_events_url":"https://api.github.com/users/Quramy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-24T18:33:44Z","updated_at":"2015-12-22T18:04:13Z","closed_at":null,"body":"日本語で失礼します. \r\n\r\n下記を実行すると、標題のErrorが発生しました.\r\n\r\n```js\r\n'use strict';\r\n\r\nvar data = require('./sourcemap-v3.json');\r\nvar parser = require('json-schema-parser');\r\n\r\nparser.parse(data);\r\n```\r\n\r\n* [sourcemap-v3.json](http://json.schemastore.org/sourcemap-v3.json)\r\n\r\nおそらく、対象のschema中にトップレベルへの参照が貼られているため、この部分の解析中に無限ループに陥るのだと思います.\r\n\r\n```json\r\n\"map\": {\r\n   \"$ref\": \"#\"\r\n}\r\n```\r\n\r\n以前に(別言語ですが)JSON Schemaの解析に迫られた際に、やはりこの循環参照問題に頭を悩ませたことがあります.\r\n「parserを自作し、Schemaの`$ref`を展開した後に、展開されたobjectを元に本処理を行う」といったアプローチを最初に試みたのですが、循環参照が発生する都合上、このアプローチは断念しました。\r\n(最終的にはoneOfやanyOfといった仕様周りに心が折れて色々諦めました...)\r\n\r\nこのレポジトリはparserの提供がメインですので、展開を断念するという選択肢は難しいかと思いますが、何らかの防御策を提供された方が良いかと思い、issueとさせて頂きました.\r\n\r\nJapanese sorry."},"comment":{"url":"https://api.github.com/repos/izumin5210/json-schema-parser/issues/comments/166691936","html_url":"https://github.com/izumin5210/json-schema-parser/issues/1#issuecomment-166691936","issue_url":"https://api.github.com/repos/izumin5210/json-schema-parser/issues/1","id":166691936,"user":{"login":"tauren","id":282084,"avatar_url":"https://avatars.githubusercontent.com/u/282084?v=3","gravatar_id":"","url":"https://api.github.com/users/tauren","html_url":"https://github.com/tauren","followers_url":"https://api.github.com/users/tauren/followers","following_url":"https://api.github.com/users/tauren/following{/other_user}","gists_url":"https://api.github.com/users/tauren/gists{/gist_id}","starred_url":"https://api.github.com/users/tauren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tauren/subscriptions","organizations_url":"https://api.github.com/users/tauren/orgs","repos_url":"https://api.github.com/users/tauren/repos","events_url":"https://api.github.com/users/tauren/events{/privacy}","received_events_url":"https://api.github.com/users/tauren/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T18:04:13Z","updated_at":"2015-12-22T18:04:13Z","body":"I'm running into this issue as well. Running this code:\r\n\r\n```\r\nimport fs from \"fs-extra\"\r\nimport * as SchemaParser from \"json-schema-parser\"\r\nvar schema = fs.readJsonSync(\"test/fixtures/simpletree.json\");\r\nvar deref = SchemaParser.parse(schema);\r\n```\r\n\r\nUsing a basic tree schema in `simpletree.json`:\r\n\r\n```\r\n{\r\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\r\n  \"title\": \"Basic Tree Schema\",\r\n  \"description\": \"Causes stack RangeError: Maximum call stack size exceeded\",\r\n  \"type\": \"object\",\r\n  \"required\": [ \"id\" ],\r\n  \"properties\": {\r\n     \"id\": {\r\n        \"type\": \"string\",\r\n        \"description\": \"The node id\"\r\n     },\r\n     \"children\": {\r\n        \"type\": \"array\",\r\n        \"items\": { \"$ref\": \"#\" }\r\n     }\r\n  }\r\n}\r\n```\r\n\r\nResults in this error:\r\n\r\n```\r\nStack:\r\nRangeError: Maximum call stack size exceeded\r\n    at unescape (/Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/node_modules/json-pointer/index.js)\r\n    at Array.map (native)\r\n    at Function.parse (/Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/node_modules/json-pointer/index.js:199:45)\r\n    at Function.get (/Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/node_modules/json-pointer/index.js:50:25)\r\n    at parse (/Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/lib/parser.js:13:29)\r\n    at /Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/lib/parser.js:18:17\r\n    at Array.forEach (native)\r\n    at parse (/Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/lib/parser.js:14:28)\r\n    at /Users/tmil11/stash/nidr/playbook-rulebook/node_modules/json-schema-parser/lib/parser.js:18:17\r\n    at Array.forEach (native)\r\n```\r\n\r\n"}}