{"action":"opened","number":11,"pull_request":{"url":"https://api.github.com/repos/camspiers/json-pretty/pulls/11","id":51938799,"html_url":"https://github.com/camspiers/json-pretty/pull/11","diff_url":"https://github.com/camspiers/json-pretty/pull/11.diff","patch_url":"https://github.com/camspiers/json-pretty/pull/11.patch","issue_url":"https://api.github.com/repos/camspiers/json-pretty/issues/11","number":11,"state":"open","locked":false,"title":"Allow is_json to be defined to skip slow isJson() call","user":{"login":"martinbutt","id":4308112,"avatar_url":"https://avatars.githubusercontent.com/u/4308112?v=3","gravatar_id":"","url":"https://api.github.com/users/martinbutt","html_url":"https://github.com/martinbutt","followers_url":"https://api.github.com/users/martinbutt/followers","following_url":"https://api.github.com/users/martinbutt/following{/other_user}","gists_url":"https://api.github.com/users/martinbutt/gists{/gist_id}","starred_url":"https://api.github.com/users/martinbutt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinbutt/subscriptions","organizations_url":"https://api.github.com/users/martinbutt/orgs","repos_url":"https://api.github.com/users/martinbutt/repos","events_url":"https://api.github.com/users/martinbutt/events{/privacy}","received_events_url":"https://api.github.com/users/martinbutt/received_events","type":"User","site_admin":false},"body":"The isJson() call takes up about >99% of runtime. I have added $is_json as an input parameter to allow the call to be skipped if you know the input format.\r\n\r\nI used this script to profile it:\r\n```php\r\nfor ($i=0; $i<1000; $i++) {\r\n        for ($j=0; $j<100; $j++) {\r\n                $arr[$i][uniqid()] = uniqid();\r\n        }\r\n}\r\n\r\n$start_time = microtime(true);\r\n$jsonPretty = new Camspiers\\JsonPretty\\JsonPretty;\r\n$converted  = $jsonPretty->prettify($arr); // pass in $is_json parameter for second run\r\necho (microtime(true) - $start_time).\"\\n\";\r\n```\r\n\r\nBefore:\r\n```\r\n0.88120579719543\r\n```\r\n\r\nAfter:\r\n```\r\n0.00054192543029785\r\n```\r\n\r\nAs you can see, this led to a speed up of almost 2000x.","created_at":"2015-11-26T18:23:50Z","updated_at":"2015-11-26T18:23:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/camspiers/json-pretty/pulls/11/commits","review_comments_url":"https://api.github.com/repos/camspiers/json-pretty/pulls/11/comments","review_comment_url":"https://api.github.com/repos/camspiers/json-pretty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/camspiers/json-pretty/issues/11/comments","statuses_url":"https://api.github.com/repos/camspiers/json-pretty/statuses/ebdc02061b1a46395bfea3790d8fffa565931220","head":{"label":"martinbutt:master","ref":"master","sha":"ebdc02061b1a46395bfea3790d8fffa565931220","user":{"login":"martinbutt","id":4308112,"avatar_url":"https://avatars.githubusercontent.com/u/4308112?v=3","gravatar_id":"","url":"https://api.github.com/users/martinbutt","html_url":"https://github.com/martinbutt","followers_url":"https://api.github.com/users/martinbutt/followers","following_url":"https://api.github.com/users/martinbutt/following{/other_user}","gists_url":"https://api.github.com/users/martinbutt/gists{/gist_id}","starred_url":"https://api.github.com/users/martinbutt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinbutt/subscriptions","organizations_url":"https://api.github.com/users/martinbutt/orgs","repos_url":"https://api.github.com/users/martinbutt/repos","events_url":"https://api.github.com/users/martinbutt/events{/privacy}","received_events_url":"https://api.github.com/users/martinbutt/received_events","type":"User","site_admin":false},"repo":{"id":46937641,"name":"json-pretty","full_name":"martinbutt/json-pretty","owner":{"login":"martinbutt","id":4308112,"avatar_url":"https://avatars.githubusercontent.com/u/4308112?v=3","gravatar_id":"","url":"https://api.github.com/users/martinbutt","html_url":"https://github.com/martinbutt","followers_url":"https://api.github.com/users/martinbutt/followers","following_url":"https://api.github.com/users/martinbutt/following{/other_user}","gists_url":"https://api.github.com/users/martinbutt/gists{/gist_id}","starred_url":"https://api.github.com/users/martinbutt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinbutt/subscriptions","organizations_url":"https://api.github.com/users/martinbutt/orgs","repos_url":"https://api.github.com/users/martinbutt/repos","events_url":"https://api.github.com/users/martinbutt/events{/privacy}","received_events_url":"https://api.github.com/users/martinbutt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/martinbutt/json-pretty","description":"Provides support for json pretty printing in php 5.3","fork":true,"url":"https://api.github.com/repos/martinbutt/json-pretty","forks_url":"https://api.github.com/repos/martinbutt/json-pretty/forks","keys_url":"https://api.github.com/repos/martinbutt/json-pretty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/martinbutt/json-pretty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/martinbutt/json-pretty/teams","hooks_url":"https://api.github.com/repos/martinbutt/json-pretty/hooks","issue_events_url":"https://api.github.com/repos/martinbutt/json-pretty/issues/events{/number}","events_url":"https://api.github.com/repos/martinbutt/json-pretty/events","assignees_url":"https://api.github.com/repos/martinbutt/json-pretty/assignees{/user}","branches_url":"https://api.github.com/repos/martinbutt/json-pretty/branches{/branch}","tags_url":"https://api.github.com/repos/martinbutt/json-pretty/tags","blobs_url":"https://api.github.com/repos/martinbutt/json-pretty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/martinbutt/json-pretty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/martinbutt/json-pretty/git/refs{/sha}","trees_url":"https://api.github.com/repos/martinbutt/json-pretty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/martinbutt/json-pretty/statuses/{sha}","languages_url":"https://api.github.com/repos/martinbutt/json-pretty/languages","stargazers_url":"https://api.github.com/repos/martinbutt/json-pretty/stargazers","contributors_url":"https://api.github.com/repos/martinbutt/json-pretty/contributors","subscribers_url":"https://api.github.com/repos/martinbutt/json-pretty/subscribers","subscription_url":"https://api.github.com/repos/martinbutt/json-pretty/subscription","commits_url":"https://api.github.com/repos/martinbutt/json-pretty/commits{/sha}","git_commits_url":"https://api.github.com/repos/martinbutt/json-pretty/git/commits{/sha}","comments_url":"https://api.github.com/repos/martinbutt/json-pretty/comments{/number}","issue_comment_url":"https://api.github.com/repos/martinbutt/json-pretty/issues/comments{/number}","contents_url":"https://api.github.com/repos/martinbutt/json-pretty/contents/{+path}","compare_url":"https://api.github.com/repos/martinbutt/json-pretty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/martinbutt/json-pretty/merges","archive_url":"https://api.github.com/repos/martinbutt/json-pretty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/martinbutt/json-pretty/downloads","issues_url":"https://api.github.com/repos/martinbutt/json-pretty/issues{/number}","pulls_url":"https://api.github.com/repos/martinbutt/json-pretty/pulls{/number}","milestones_url":"https://api.github.com/repos/martinbutt/json-pretty/milestones{/number}","notifications_url":"https://api.github.com/repos/martinbutt/json-pretty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/martinbutt/json-pretty/labels{/name}","releases_url":"https://api.github.com/repos/martinbutt/json-pretty/releases{/id}","created_at":"2015-11-26T16:41:33Z","updated_at":"2015-11-26T16:41:34Z","pushed_at":"2015-11-26T18:16:57Z","git_url":"git://github.com/martinbutt/json-pretty.git","ssh_url":"git@github.com:martinbutt/json-pretty.git","clone_url":"https://github.com/martinbutt/json-pretty.git","svn_url":"https://github.com/martinbutt/json-pretty","homepage":null,"size":24,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"camspiers:master","ref":"master","sha":"73c0bd55ca966f31f79d690a4b0aabaf98ad5d94","user":{"login":"camspiers","id":51294,"avatar_url":"https://avatars.githubusercontent.com/u/51294?v=3","gravatar_id":"","url":"https://api.github.com/users/camspiers","html_url":"https://github.com/camspiers","followers_url":"https://api.github.com/users/camspiers/followers","following_url":"https://api.github.com/users/camspiers/following{/other_user}","gists_url":"https://api.github.com/users/camspiers/gists{/gist_id}","starred_url":"https://api.github.com/users/camspiers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camspiers/subscriptions","organizations_url":"https://api.github.com/users/camspiers/orgs","repos_url":"https://api.github.com/users/camspiers/repos","events_url":"https://api.github.com/users/camspiers/events{/privacy}","received_events_url":"https://api.github.com/users/camspiers/received_events","type":"User","site_admin":false},"repo":{"id":7858273,"name":"json-pretty","full_name":"camspiers/json-pretty","owner":{"login":"camspiers","id":51294,"avatar_url":"https://avatars.githubusercontent.com/u/51294?v=3","gravatar_id":"","url":"https://api.github.com/users/camspiers","html_url":"https://github.com/camspiers","followers_url":"https://api.github.com/users/camspiers/followers","following_url":"https://api.github.com/users/camspiers/following{/other_user}","gists_url":"https://api.github.com/users/camspiers/gists{/gist_id}","starred_url":"https://api.github.com/users/camspiers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camspiers/subscriptions","organizations_url":"https://api.github.com/users/camspiers/orgs","repos_url":"https://api.github.com/users/camspiers/repos","events_url":"https://api.github.com/users/camspiers/events{/privacy}","received_events_url":"https://api.github.com/users/camspiers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/camspiers/json-pretty","description":"Provides support for json pretty printing in php 5.3","fork":false,"url":"https://api.github.com/repos/camspiers/json-pretty","forks_url":"https://api.github.com/repos/camspiers/json-pretty/forks","keys_url":"https://api.github.com/repos/camspiers/json-pretty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/camspiers/json-pretty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/camspiers/json-pretty/teams","hooks_url":"https://api.github.com/repos/camspiers/json-pretty/hooks","issue_events_url":"https://api.github.com/repos/camspiers/json-pretty/issues/events{/number}","events_url":"https://api.github.com/repos/camspiers/json-pretty/events","assignees_url":"https://api.github.com/repos/camspiers/json-pretty/assignees{/user}","branches_url":"https://api.github.com/repos/camspiers/json-pretty/branches{/branch}","tags_url":"https://api.github.com/repos/camspiers/json-pretty/tags","blobs_url":"https://api.github.com/repos/camspiers/json-pretty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/camspiers/json-pretty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/camspiers/json-pretty/git/refs{/sha}","trees_url":"https://api.github.com/repos/camspiers/json-pretty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/camspiers/json-pretty/statuses/{sha}","languages_url":"https://api.github.com/repos/camspiers/json-pretty/languages","stargazers_url":"https://api.github.com/repos/camspiers/json-pretty/stargazers","contributors_url":"https://api.github.com/repos/camspiers/json-pretty/contributors","subscribers_url":"https://api.github.com/repos/camspiers/json-pretty/subscribers","subscription_url":"https://api.github.com/repos/camspiers/json-pretty/subscription","commits_url":"https://api.github.com/repos/camspiers/json-pretty/commits{/sha}","git_commits_url":"https://api.github.com/repos/camspiers/json-pretty/git/commits{/sha}","comments_url":"https://api.github.com/repos/camspiers/json-pretty/comments{/number}","issue_comment_url":"https://api.github.com/repos/camspiers/json-pretty/issues/comments{/number}","contents_url":"https://api.github.com/repos/camspiers/json-pretty/contents/{+path}","compare_url":"https://api.github.com/repos/camspiers/json-pretty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/camspiers/json-pretty/merges","archive_url":"https://api.github.com/repos/camspiers/json-pretty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/camspiers/json-pretty/downloads","issues_url":"https://api.github.com/repos/camspiers/json-pretty/issues{/number}","pulls_url":"https://api.github.com/repos/camspiers/json-pretty/pulls{/number}","milestones_url":"https://api.github.com/repos/camspiers/json-pretty/milestones{/number}","notifications_url":"https://api.github.com/repos/camspiers/json-pretty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/camspiers/json-pretty/labels{/name}","releases_url":"https://api.github.com/repos/camspiers/json-pretty/releases{/id}","created_at":"2013-01-27T21:23:07Z","updated_at":"2015-08-31T20:35:50Z","pushed_at":"2015-09-17T16:06:32Z","git_url":"git://github.com/camspiers/json-pretty.git","ssh_url":"git@github.com:camspiers/json-pretty.git","clone_url":"https://github.com/camspiers/json-pretty.git","svn_url":"https://github.com/camspiers/json-pretty","homepage":null,"size":206,"stargazers_count":9,"watchers_count":9,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/camspiers/json-pretty/pulls/11"},"html":{"href":"https://github.com/camspiers/json-pretty/pull/11"},"issue":{"href":"https://api.github.com/repos/camspiers/json-pretty/issues/11"},"comments":{"href":"https://api.github.com/repos/camspiers/json-pretty/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/camspiers/json-pretty/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/camspiers/json-pretty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/camspiers/json-pretty/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/camspiers/json-pretty/statuses/ebdc02061b1a46395bfea3790d8fffa565931220"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":101,"deletions":7,"changed_files":2}}