{"action":"created","issue":{"url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/issues/41","repository_url":"https://api.github.com/repos/LinkedDataFragments/Server.Java","labels_url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/issues/41/comments","events_url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/issues/41/events","html_url":"https://github.com/LinkedDataFragments/Server.Java/issues/41","id":197019203,"number":41,"title":"JSON-LD issues with P_ keys","user":{"login":"RubenVerborgh","id":675313,"avatar_url":"https://avatars.githubusercontent.com/u/675313?v=3","gravatar_id":"","url":"https://api.github.com/users/RubenVerborgh","html_url":"https://github.com/RubenVerborgh","followers_url":"https://api.github.com/users/RubenVerborgh/followers","following_url":"https://api.github.com/users/RubenVerborgh/following{/other_user}","gists_url":"https://api.github.com/users/RubenVerborgh/gists{/gist_id}","starred_url":"https://api.github.com/users/RubenVerborgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RubenVerborgh/subscriptions","organizations_url":"https://api.github.com/users/RubenVerborgh/orgs","repos_url":"https://api.github.com/users/RubenVerborgh/repos","events_url":"https://api.github.com/users/RubenVerborgh/events{/privacy}","received_events_url":"https://api.github.com/users/RubenVerborgh/received_events","type":"User","site_admin":false},"labels":[{"id":98588582,"url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":{"login":"mielvds","id":1032980,"avatar_url":"https://avatars.githubusercontent.com/u/1032980?v=3","gravatar_id":"","url":"https://api.github.com/users/mielvds","html_url":"https://github.com/mielvds","followers_url":"https://api.github.com/users/mielvds/followers","following_url":"https://api.github.com/users/mielvds/following{/other_user}","gists_url":"https://api.github.com/users/mielvds/gists{/gist_id}","starred_url":"https://api.github.com/users/mielvds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mielvds/subscriptions","organizations_url":"https://api.github.com/users/mielvds/orgs","repos_url":"https://api.github.com/users/mielvds/repos","events_url":"https://api.github.com/users/mielvds/events{/privacy}","received_events_url":"https://api.github.com/users/mielvds/received_events","type":"User","site_admin":false},"assignees":[{"login":"mielvds","id":1032980,"avatar_url":"https://avatars.githubusercontent.com/u/1032980?v=3","gravatar_id":"","url":"https://api.github.com/users/mielvds","html_url":"https://github.com/mielvds","followers_url":"https://api.github.com/users/mielvds/followers","following_url":"https://api.github.com/users/mielvds/following{/other_user}","gists_url":"https://api.github.com/users/mielvds/gists{/gist_id}","starred_url":"https://api.github.com/users/mielvds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mielvds/subscriptions","organizations_url":"https://api.github.com/users/mielvds/orgs","repos_url":"https://api.github.com/users/mielvds/repos","events_url":"https://api.github.com/users/mielvds/events{/privacy}","received_events_url":"https://api.github.com/users/mielvds/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-12-21T19:56:37Z","updated_at":"2016-12-21T20:32:09Z","closed_at":null,"body":"Reported by Lucas Werkmeister on [the Wikidata mailing list](https://lists.wikimedia.org/pipermail/wikidata/2016-December/010057.html)\r\n\r\nI tried playing with it a bit and noticed an oddity in the JSON format:\r\nif the predicate and object are both left unspecified, \"P_\" keys will\r\nsometimes refer to full statement nodes and sometimes to truthy values.\r\nAn example item with not too many statements where you can witness this\r\nis Q26536085:\r\n\r\n```\r\ncurl -s -H 'Accept: application/ld+json'\r\n'https://query.wikidata.org/bigdata/ldf?subject=http%3A//www.wikidata.org/entity/Q26536085&predicate=&object='\r\n| jq '.[\"@graph\"] | .[] | select(.[\"@id\"]==\"wd:Q26536085\")'\r\n```\r\n\r\nRight now, I get the following results:\r\n\r\n```\r\n  \"P1216\": \"wds:Q26536085-FCED904F-7F06-444A-84CE-0AFCE089C92C\",\r\n  \"p:P131\": {\r\n    \"@id\": \"wds:Q26536085-44302E43-6F33-4F4A-9783-BD631171BF43\"\r\n  },\r\n  \"p:P1435\": {\r\n    \"@id\": \"wds:Q26536085-01720F88-7A41-47C6-84FA-74F5E7538CDC\"\r\n  },\r\n  \"P17\": \"wds:Q26536085-8D04E875-1CD8-4A53-BCC9-1B8591A4AE78\",\r\n  \"p:P31\": {\r\n    \"@id\": \"wds:Q26536085-6CBDDC3D-632A-41C3-8E3B-D9E1D0C103F7\"\r\n  },\r\n  \"P625\": \"wds:Q26536085-49F66E15-7AE7-44D6-95CE-A4955734EA07\",\r\n  \"wdt:P1216\": \"1243406\",\r\n  \"P131\": \"wd:Q635457\",\r\n  \"P1435\": \"wd:Q15700834\",\r\n  \"wdt:P17\": {\r\n    \"@id\": \"wd:Q145\"\r\n  },\r\n  \"P31\": \"wd:Q3947\",\r\n  \"wdt:P625\": {\r\n    \"@type\": \"geo:wktLiteral\",\r\n    \"@value\": \"Point(-2.027844 51.36333)\"\r\n  }\r\n```\r\n\r\nAs you can see, the \"P_\" key sometimes refers to the full statement node\r\n(\"wds:_\") and sometimes to the direct, truthy value (\"wd:Q_\"). Where\r\n\"P_\" points to the statement node, there’s also a \"wdt:P_\" entry\r\n(sometimes pointing directly at a string containing the ID, sometimes\r\npointing to an { \"@id\": _ } object); conversely, where \"P_\" points to\r\nthe truthy value, there’s a \"p:P_\" entry to an { \"@id\": _ } object.\r\n\r\nIs there any reason why different representations are chosen? Is this\r\npredictable? Is this a bug? Or is this just something you have to work\r\naround using the @context information if you want to use the JSON\r\nformat? (The other data formats don’t seem to have this problem, since\r\nthey don’t use unprefixed \"P_\" keys.)"},"comment":{"url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/issues/comments/268631595","html_url":"https://github.com/LinkedDataFragments/Server.Java/issues/41#issuecomment-268631595","issue_url":"https://api.github.com/repos/LinkedDataFragments/Server.Java/issues/41","id":268631595,"user":{"login":"RubenVerborgh","id":675313,"avatar_url":"https://avatars.githubusercontent.com/u/675313?v=3","gravatar_id":"","url":"https://api.github.com/users/RubenVerborgh","html_url":"https://github.com/RubenVerborgh","followers_url":"https://api.github.com/users/RubenVerborgh/followers","following_url":"https://api.github.com/users/RubenVerborgh/following{/other_user}","gists_url":"https://api.github.com/users/RubenVerborgh/gists{/gist_id}","starred_url":"https://api.github.com/users/RubenVerborgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RubenVerborgh/subscriptions","organizations_url":"https://api.github.com/users/RubenVerborgh/orgs","repos_url":"https://api.github.com/users/RubenVerborgh/repos","events_url":"https://api.github.com/users/RubenVerborgh/events{/privacy}","received_events_url":"https://api.github.com/users/RubenVerborgh/received_events","type":"User","site_admin":false},"created_at":"2016-12-21T20:32:09Z","updated_at":"2016-12-21T20:32:09Z","body":"@smalyshev replied:\r\n\r\n> After thinking a bit about it I *think* I've found the logic behind it:\r\nwhen it encounters first P-statement, it uses only suffix and puts the\r\nfull URL in @context. However when it encounters second URI with the\r\nsame suffix, it uses the prefix and then there's no need in @context.\r\nSince the statements can be encountered in any order in the DB, it's not\r\nconsistent which of the two gets @context and which gets prefix.\r\n> \r\n> The algorithm for parsing it would be checking if the key has :, if yes,\r\nresolve against prefix, if not - resolve against @context."}}
{"actor":{"display_login":"RubenVerborgh"}}