Enable sorting of keys during serde serialization

This commit is contained in:
Filip Tibell 2023-08-23 15:11:12 -05:00
parent f3afbcadd0
commit 64b152e34b
No known key found for this signature in database
3 changed files with 8 additions and 5 deletions

View file

@ -42,6 +42,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Serving requests using `net.serve` now processes requests on background threads, also freeing up resources. In the future, this will also allow us to offload heavy tasks such as compression/decompression to background threads. - Serving requests using `net.serve` now processes requests on background threads, also freeing up resources. In the future, this will also allow us to offload heavy tasks such as compression/decompression to background threads.
- Groundwork for custom / user-defined require aliases has been implemented, as well as absolute / cwd-relative requires. These will both be exposed as options and be made available to use some time in the future. - Groundwork for custom / user-defined require aliases has been implemented, as well as absolute / cwd-relative requires. These will both be exposed as options and be made available to use some time in the future.
- When using the `serde` built-in library, keys are now sorted during serialization. This means that the output of `encode` is now completely deterministic, and wont cause issues when committing generated files to git etc.
### Fixed ### Fixed
- Fixed not being able to pass arguments to the thread using `coroutine.resume`. ([#86]) - Fixed not being able to pass arguments to the thread using `coroutine.resume`. ([#86])

View file

@ -10,6 +10,7 @@ const LUA_SERIALIZE_OPTIONS: LuaSerializeOptions = LuaSerializeOptions::new()
.serialize_unit_to_null(false); .serialize_unit_to_null(false);
const LUA_DESERIALIZE_OPTIONS: LuaDeserializeOptions = LuaDeserializeOptions::new() const LUA_DESERIALIZE_OPTIONS: LuaDeserializeOptions = LuaDeserializeOptions::new()
.sort_keys(true)
.deny_recursive_tables(false) .deny_recursive_tables(false)
.deny_unsupported_types(true); .deny_unsupported_types(true);

View file

@ -1,15 +1,15 @@
local JSON_STRING = [[{"Hello":"World","Inner":{"Array":[1,2,3]},"Foo":"Bar"}]] local JSON_STRING = [[{"Foo":"Bar","Hello":"World","Inner":{"Array":[1,3,2]}}]]
local JSON_STRING_PRETTY = [[{ local JSON_STRING_PRETTY = [[{
"Foo": "Bar",
"Hello": "World", "Hello": "World",
"Inner": { "Inner": {
"Array": [ "Array": [
1, 1,
2, 3,
3 2
] ]
}, }
"Foo": "Bar"
}]] }]]
return { return {