#1 2020-03-05 08:11:16

ertank
Member
Registered: 2016-03-16
Posts: 168

Json de-serialization order

Hello,

I have a problem de-serializing a json string. After I get false from de-serialization function, I see some variables have value in my record.

In order to find my mistake, I would like to understand how mORMot doing de-serializing order.

For example I have below json string:

{"name":"test","surname":"test"}

And my record definition is:

type
  TPerson = packed record
    surname: string;
    name: string;
  end;

When de-serializing, is it name or surname that is filled in record variable first?

Thanks & regards,
Ertan

Offline

#2 2020-03-05 08:35:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Json de-serialization order

{"name":"testname","surname":"testsurname"}

Will set 'testname' into TPerson.name and 'testsurname' into TPerson.surname.
There is no such thing as "fill order"... it just put the right values in the right fields.
Note: if the record and the JSON have the same order, then it may be slightly faster to work with (no need to lookup the field name).

Online

Board footer

Powered by FluxBB