Decoder result sorting

Good day, I ask for help in solving the problem.
Chirpstak version 4.3
Help in fixing the decoder, tell me how to correctly display the values in order?
In the web interface in the object field, the names are constantly changing places

Here is a sample code

function decodeUplink(input) {
varbytes = input.bytes;

var Packet_type = 1; //1.Packet_type, bytes 0
var SN_string = 2; //2.SN, bytes 1-4
var OS_Version = 3; //3.OS version, bytes 5-6

return {
data: {
“01.TYPE”: Packet_type,
“02.SN”: SN_string,
“03.OS_Version”: OS_Version,


I believe the order of items in a JSON is not guaranteed.

1 Like

Chirpstack version 3 does not have this problem.

This is not a problem, keys of an object are not guaranteed to be in order and your parser should never rely on keys being ordered, even in v3 there is no guarantee.

If you want to guarantee an order, change your data-model in an array of objects, e.g.

  "data": [
    {"key": "01.TYPE", "value": "..."},
    {"key": "02.SN", "value": "..."},

(note that even in this case, the order of "key" and "value" might change)