PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org/docs/Introduction
MIT License
337 stars 20 forks source link

Bias json.encode more towards arrays, but allow __order to explicitly declare an object #870

Closed Sainan closed 1 month ago

Sainan commented 1 month ago

Currently, the semantics are not so great:

This fixes both by adding the following semantics:

assert(json.encode({}) == "[]")
assert(json.encode({ __order = {} }) == "{}")