#1 2024-12-04 18:22:01

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 135

From mORMot 1 to 2

Hello friends,

My first post about mORMot2, I started the task of migrating to version 2, I have code like this in several files:

  // mORMot 1
  TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TMyClass), __TMyClass).Options := [soReadIgnoreUnknownFields,soWriteHumanReadable];

I am trying to determine what the equivalent code would be now

  // mORMot 2
  TRttiJson.RegisterFromText(TypeInfo(TMyClass), __TMyClass, [jpoIgnoreUnknownProperty],[]);

This code compiles without error but before I change all the similar lines I would like to hear your advice

Last edited by moctes (2024-12-04 18:24:56)

Offline

#2 2024-12-04 18:34:59

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

Re: From mORMot 1 to 2

I am not sure jpoIgnoreUnknownProperty is mandatory, because it would depend how it is parsed.
For the SOA it is set by default - no need to add it.

Then you can use TRttiJson.RegisterFromText([ ]) with pairs - as we do in our usual code.

Offline

#3 2024-12-04 18:43:20

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 135

Re: From mORMot 1 to 2

Thank you ! 

If I have more questions I will ask them in this same post.

Offline

Board footer

Powered by FluxBB