• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / tarantool / 11674415344
88%

Build:
DEFAULT BRANCH: master
Ran 04 Nov 2024 11:32PM UTC
Jobs 1
Files 516
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

04 Nov 2024 11:21PM UTC coverage: 87.31% (-0.003%) from 87.313%
11674415344

push

github

Totktonada
lua: add `encode_key_order` option to json encoder

This option allows to pass an array of keys that will be used to sort
keys in maps during serialization to json. The order of the provided keys
in the resulting string will be the same as in the `encode_key_order`
array. Keys, present in maps and not included in `encode_key_order` will
be serialized after the sorted ones in arbitrary order.

Closes #10606

@TarantoolBot document
Title: A new `encode_key_order` option for json encoder introduced
Product: Tarantool
Since: 3.3.0

This option allows to specify the order in which the keys of object will be
serialized. To specify a particular order, it is possible to pass an
array of the keys, and resulting JSON string will contain the provided
keys in the specified order, while other present keys of an object will
be present after in some arbitrary order.

``` lua
map = {a = 1, c = 100, b = 2}

require('json').encode(map)
-- returns '{"b":2,"a":1,"c":100}'

require('json').encode(map, {encode_key_order = {'a', 'b'}})
-- returns '{"a":1,"b":2,"c":100}'

require('json').(map, {encode_key_order = {'a', 'b', 'd'}})
-- returns '{"a":1,"b":2,"c":100}'
```

For a persistent serializer object a persistent ordering can be defined:
``` lua
map_1 = {a = 1, c = 100, b = 2}

j = require('json').new()
j.cfg({encode_key_order = {'a', 'b'}})

j.encode(map_1)
-- returns '{"a":1,"b":2,"c":100}'

j.encode(map_1, {encode_key_order = {'c', 'b'}})
-- returns '{"c":100,"b":2,"a":1}'

j.encode(map_1)
-- returns '{"a":1,"b":2,"c":100}'
```

69310 of 123132 branches covered (56.29%)

134 of 144 new or added lines in 1 file covered. (93.06%)

38 existing lines in 16 files now uncovered.

102166 of 117015 relevant lines covered (87.31%)

2747036.79 hits per line

Jobs
ID Job ID Ran Files Coverage
1 11674415344.1 04 Nov 2024 11:32PM UTC 0
87.31
GitHub Action Run
Source Files on build 11674415344
Detailed source file information is not available for this build.
  • Back to Repo
  • 8806b7b5 on github
  • Prev Build on master (#11630463599)
  • Next Build on master (#11684010822)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc