#1 2022-07-20 09:00:01

Charly52
Member
From: Germany
Registered: 2022-07-20
Posts: 9

JSON Serialization of record

Hi all,

I am new here and not shure whether I am right at this point.
If not please apologize me and put me through to the correct position.

My question:

I found an article depending on "JSON serialization of records" at this address:
https://blog.synopse.info/?post/2014/05 … anced-RTTI

And my problem is. I don't know the environement and structur of your projects/Sources
The syncommon.pas  is member of wich project?
Can it be used "standalone" or do I need som more?

What must I download from where to realise a serialization in delphi 10.4?


best regards and thank you all for help

Charly

Offline

#2 2022-07-20 09:12:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: JSON Serialization of record

SynCommons is part of mORMot 1 = https://github.com/synopse/mORMot

And you have a new version in mORMot 2 = https://github.com/synopse/mORMot2

But it is part of the whole framework, especially for mORMot 2, which has split SynCommons.pas into smaller - and more maintainable - units.

Offline

#3 2022-07-20 15:04:27

Charly52
Member
From: Germany
Registered: 2022-07-20
Posts: 9

Re: JSON Serialization of record

Hi ab,

i did it as in the README.md  at  github.com/synopse/mORMot2  is written.

Downloaded the Project and the momot2static.7z, extracted this at ../static
created a environment variable mormot2 and
entered the path-string to the  IDE lobrary path.
I work with  Delphi 10.4 Community

A can open the ../test/mormot2tests.dproj
during compilation I got the error:

[dcc32 Error] mormot.core.variants.pas(5104): E2250 There is no overloaded version of 'SaveToJson' that can be called with these arguments


  if item.Kind in (rkRecordOrDynArrayTypes + [rkClass]) then
  begin
    // use temporary non-expanded JSON conversion for complex nested content
//    aItems.SaveToJson(json, [twoNonExpandedArrays]);             
    aItems.SaveToJson(json, false);       <------------------------------------   so it compiles well!!!!


Do I have  a wrong   mormot.core.data??

Charly

Offline

#4 2022-07-20 15:53:43

tbo
Member
Registered: 2015-04-20
Posts: 224

Re: JSON Serialization of record

This is a mistake in commit 20d34d0. Try this:

aItems.SaveToJson(json, False, [twoNonExpandedArrays]);

With best regards
Thomas

Offline

#5 2022-07-20 16:28:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: JSON Serialization of record

You should have waited a little bit for the upcoming commit, I guess.
smile

Or pickup a release in github, which was tested to be stable.

Offline

#6 2022-07-20 16:54:21

Charly52
Member
From: Germany
Registered: 2022-07-20
Posts: 9

Re: JSON Serialization of record

Danke!

I found an other point to fix.

In the description   https://github.com/synopse/mORMot2 Quick Start
in the path list
$(mormot2)\src\core;$(mormot2)\src\db;$(mormot2)\src\rest;$(mormot2)\src\crypt;$(mormot2)\src\script;$(mormot2)\src\app;$(mormot2)\src\net;$(mormot2)\src\orm;$(mormot2)\src\soa;$(mormot2)\src\lib

the entry :  $(mormot2)\src   is missing.
Without this, in my IDE the    mormot.defines.inc    isn't found.

Charly

Offline

#7 2022-07-21 09:09:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: JSON Serialization of record

You are right.

Should be fixed by https://github.com/synopse/mORMot2/commit/5c1329a8

Offline

Board footer

Powered by FluxBB