{"action":"created","issue":{"url":"https://api.github.com/repos/jgm/pandoc/issues/3211","repository_url":"https://api.github.com/repos/jgm/pandoc","labels_url":"https://api.github.com/repos/jgm/pandoc/issues/3211/labels{/name}","comments_url":"https://api.github.com/repos/jgm/pandoc/issues/3211/comments","events_url":"https://api.github.com/repos/jgm/pandoc/issues/3211/events","html_url":"https://github.com/jgm/pandoc/issues/3211","id":187170031,"number":3211,"title":"Can I assume that `pandoc-api-version` always appears first?","user":{"login":"sergiocorreia","id":214056,"avatar_url":"https://avatars.githubusercontent.com/u/214056?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiocorreia","html_url":"https://github.com/sergiocorreia","followers_url":"https://api.github.com/users/sergiocorreia/followers","following_url":"https://api.github.com/users/sergiocorreia/following{/other_user}","gists_url":"https://api.github.com/users/sergiocorreia/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiocorreia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiocorreia/subscriptions","organizations_url":"https://api.github.com/users/sergiocorreia/orgs","repos_url":"https://api.github.com/users/sergiocorreia/repos","events_url":"https://api.github.com/users/sergiocorreia/events{/privacy}","received_events_url":"https://api.github.com/users/sergiocorreia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-03T19:40:17Z","updated_at":"2016-11-03T22:09:28Z","closed_at":null,"body":"On my system (and on the TravisCI systems), Pandoc outputs a predictable JSON:\r\n\r\n```\r\n>>> echo a | pandoc --to=json\r\n{\"pandoc-api-version\":[1,17,0,4],\"meta\":{},\"blocks\":[{\"t\":\"Para\",\"c\":[{\"t\":\"Str\",\"c\":\"a\"}]}]}\r\n```\r\n\r\nHowever, I've got some reports [*](https://github.com/sergiocorreia/panflute/commit/2686e76f0574aa6c8a0b353255340ad37907e3a4) that this is not always the case:\r\n\r\n```\r\n>>> cat pftest.md | pandoc -t json\r\n{\"blocks\":[{\"t\":\"Para\",\"c\" ...\r\n```\r\n\r\nIn both cases we had the latest Pandoc version:\r\n\r\n```\r\n    pandoc 1.18\r\n    Compiled with pandoc-types 1.17.0.4, texmath 0.8.6.6, highlighting-kate 0.6.3\r\n```\r\n\r\nIs this a bug, or is there no guarantee about the order of the elements in a map? I monkey-patched panflute to work around different orders at the first level, but doing the same for all the \"t\" and \"c\" items would be a bit messy..\r\n\r\nThanks,\r\nS"},"comment":{"url":"https://api.github.com/repos/jgm/pandoc/issues/comments/258289244","html_url":"https://github.com/jgm/pandoc/issues/3211#issuecomment-258289244","issue_url":"https://api.github.com/repos/jgm/pandoc/issues/3211","id":258289244,"user":{"login":"sergiocorreia","id":214056,"avatar_url":"https://avatars.githubusercontent.com/u/214056?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiocorreia","html_url":"https://github.com/sergiocorreia","followers_url":"https://api.github.com/users/sergiocorreia/followers","following_url":"https://api.github.com/users/sergiocorreia/following{/other_user}","gists_url":"https://api.github.com/users/sergiocorreia/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiocorreia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiocorreia/subscriptions","organizations_url":"https://api.github.com/users/sergiocorreia/orgs","repos_url":"https://api.github.com/users/sergiocorreia/repos","events_url":"https://api.github.com/users/sergiocorreia/events{/privacy}","received_events_url":"https://api.github.com/users/sergiocorreia/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T22:09:28Z","updated_at":"2016-11-03T22:09:28Z","body":"Sure, it's unordered, but at the same time you control the implementation which is why I'm asking. For instance, I haven't had a single instance of 't' appearing after 'c' , and I relied on that to speed up the JSON decoding significantly. Other advantages are:\r\n\r\n- It's easier to test if a filter package (pandocfilters, panflute, etc.) is correct if it's idempotent wrt the JSON input (I just see if two files are the same).\r\n- It's easier to diff (you can use standard git diff instead of specialized JSON diffs)\r\n- It's faster to process. If pandoc-api-version appears early on, I can read that and process the data conditional on the version\r\n\r\nI don't know if writing a deterministic JSON is trivial on the Haskell side or not. If it's a big task and would mess up the codebase, then the clear choice would be to rewrite parts of panflute to be order-agnostic, even at the cost of speed. If it's completely trivial, then it might even make it easier for Pandoc when debugging.\r\n\r\nOn a related note, JSON feels quite verbose compared to native format, perhaps something like [messagePack](http://msgpack.org/index.html), or taking out the `\"t\"/\"c\"` tags could help in the longer term\r\n"}}
{"actor":{"display_login":"sergiocorreia"}}