{"action":"created","issue":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4207","repository_url":"https://api.github.com/repos/pioneerspacesim/pioneer","labels_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4207/labels{/name}","comments_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4207/comments","events_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4207/events","html_url":"https://github.com/pioneerspacesim/pioneer/pull/4207","id":283734944,"node_id":"MDExOlB1bGxSZXF1ZXN0MTU5NTQ4Mjc0","number":4207,"title":"Pickle Lua values to JSON","user":{"login":"johnbartholomew","id":115749,"node_id":"MDQ6VXNlcjExNTc0OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/115749?v=4","gravatar_id":"","url":"https://api.github.com/users/johnbartholomew","html_url":"https://github.com/johnbartholomew","followers_url":"https://api.github.com/users/johnbartholomew/followers","following_url":"https://api.github.com/users/johnbartholomew/following{/other_user}","gists_url":"https://api.github.com/users/johnbartholomew/gists{/gist_id}","starred_url":"https://api.github.com/users/johnbartholomew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnbartholomew/subscriptions","organizations_url":"https://api.github.com/users/johnbartholomew/orgs","repos_url":"https://api.github.com/users/johnbartholomew/repos","events_url":"https://api.github.com/users/johnbartholomew/events{/privacy}","received_events_url":"https://api.github.com/users/johnbartholomew/received_events","type":"User","site_admin":false},"labels":[{"id":127738332,"node_id":"MDU6TGFiZWwxMjc3MzgzMzI=","url":"https://api.github.com/repos/pioneerspacesim/pioneer/labels/Savegame%20bump","name":"Savegame bump","color":"ff7fff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2017-12-21T00:16:44Z","updated_at":"2018-09-21T09:33:36Z","closed_at":"2018-09-20T21:40:46Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/4207","html_url":"https://github.com/pioneerspacesim/pioneer/pull/4207","diff_url":"https://github.com/pioneerspacesim/pioneer/pull/4207.diff","patch_url":"https://github.com/pioneerspacesim/pioneer/pull/4207.patch"},"body":"*Updated 2018-09-02*\r\n\r\nI've only done very superficial tests.\r\n\r\nThis replaces some of the custom bytestream serialization of Lua objects to generate JSON values instead. Long term I don't like this because it's likely to be very slow (both on save and on load), but short term it means that much more of the save file can be examined and interpreted by a person with a text editor (after decompressing the save), which is potentially valuable for debugging save problems.\r\n\r\nWhen saving it just outputs the JSON version. When loading it will prefer to load the JSON version if available, but can load bytestream serialised data (ie, existing saves from before this PR) otherwise.\r\n\r\nLua->JSON structure:\r\n\r\n- nil -> null\r\n- bool -> bool\r\n- integer -> integer\r\n- string -> string (will definitely break for strings containing nul characters)\r\n- userdata (LuaObject) -> `{ \"userdata\": { \"cpp_class\": \"<...>\", \"inner\": <...> } }`\r\n- number (float) -> `{ \"number\": <... uses DoubleToStr ...> }`\r\n- plain table -> `{ \"ref\": <unique ID number for the object>, \"table\": [ <table slots in array form; an array because JSON doesn't allow non-string keys for objects> ] }`\r\n- Lua \"class\" (table with a metatable & Lua serialiser functions) -> `{ \"ref\": <unique ID>, \"table\": [ <table data> ], \"lua_class\": \"<...>\" }`\r\n- Lua back-reference (reference to table that has been serialised previously; required to support circular references in tables) -> `{ \"ref\": <unique ID> }`\r\n\r\nLuaRef structure: `{ \"lua_ref_json\": <... Lua value structured as above ...> }`\r\n\r\nLuaObject structure: Depends on the type of object (but see \"userdata\" above).\r\n\r\n----\r\n\r\n**Previously:**\r\n\r\nCurrent problems/remaining todo:\r\n- Doesn't bump save version but won't be able to load files generated from previous versions. This could be fixed pretty easily by branching to the old or new unpickle code based based on what JSON value type is being unpickled. Or just bump save version and break all old saves again for simplicity.\r\n- LuaObject values (e.g., various C++ objects that are exposed to Lua) are still pickled to a mostly-opaque bytestream. The reverse (LuaRef objects, which are Lua objects that are exposed to C++) are pickled to JSON.\r\n\r\nWould work best combined with #4205 so that a custom extraction program isn't required to decompress the save files."},"comment":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/comments/423474099","html_url":"https://github.com/pioneerspacesim/pioneer/pull/4207#issuecomment-423474099","issue_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/4207","id":423474099,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzQ3NDA5OQ==","user":{"login":"fluffyfreak","id":825083,"node_id":"MDQ6VXNlcjgyNTA4Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/825083?v=4","gravatar_id":"","url":"https://api.github.com/users/fluffyfreak","html_url":"https://github.com/fluffyfreak","followers_url":"https://api.github.com/users/fluffyfreak/followers","following_url":"https://api.github.com/users/fluffyfreak/following{/other_user}","gists_url":"https://api.github.com/users/fluffyfreak/gists{/gist_id}","starred_url":"https://api.github.com/users/fluffyfreak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fluffyfreak/subscriptions","organizations_url":"https://api.github.com/users/fluffyfreak/orgs","repos_url":"https://api.github.com/users/fluffyfreak/repos","events_url":"https://api.github.com/users/fluffyfreak/events{/privacy}","received_events_url":"https://api.github.com/users/fluffyfreak/received_events","type":"User","site_admin":false},"created_at":"2018-09-21T09:33:36Z","updated_at":"2018-09-21T09:33:36Z","author_association":"CONTRIBUTOR","body":"Yeah I'd like us to do better than that, get a PR and get it done asap. Author able of course."}}
{"actor":{"display_login":"fluffyfreak"}}