#1 Re: mORMot 2 » Deserializing JSON on mormot2 » 2026-01-09 18:43:17

Hello,

I checked the mormot2 have the method CatalogModel.FillFrom(JsonString), that I can use to fill the properties for a model. In that, case we dont have the boolean value to check but we can fill the properties for a model with the value from a JSON.

Thank you for the help tbo

#2 Re: mORMot 2 » Deserializing JSON on mormot2 » 2026-01-09 14:44:28

Hi tbo,

Thank you for the fast response.
I tried to use this

JsonToObject(CatalogModel, Pointer(Json), Valid, Nil, JSONPARSER_TOLERANTOPTIONS);

But I still facing the same behavior. If my application class dont have an property present in the JSON, the Valid is false and the properties on CatalogModel is not filled.

Do you have any other suggestion?

Thanks

#3 mORMot 2 » Deserializing JSON on mormot2 » 2026-01-08 21:15:24

StraighFree
Replies: 4

Hello,

I'm using the mormot2 in a project. In this project I make one request to a external API. This API was returning the following object:

{
    "id": 1,
    "name": null,
    "language_id": null,
    "created_at": "2025-08-22T03:54:57.000000Z",
    "updated_at": "2025-08-22T03:54:57.000000Z",
    "active": true
}

And I'm using this code to get the catalog and synchronize in my application:

procedure TSyncThread.SyncCatalog;
var
  Json: RawUtf8;
  Valid: Boolean;
  CatalogVar: variant;
  CatalogModel: TCatalog;
begin
  try
    Valid := false;
    Json := StringToUtf8(FApiConnector.getCatalog);

    CatalogVar := _JsonFast(Json);

    try
      CatalogModel := TCatalog.Create;
      JsonToObject(CatalogModel, Pointer(Json), Valid);
      if (Valid) then
      begin
        TDatabaseServer.GetInstance.getServer.CreateOrUpdate(CatalogModel);
        SyncCategories(CatalogVar.categories);
      end;
    finally
      CatalogModel.Free;
    end;
  except
    on exception do
    raise;
  end;
end;

After some time, the external API was changed and introduced a new property position to the API response:

{
    "id": 1,
    "name": null,
    "language_id": null,
    "created_at": "2025-08-22T03:54:57.000000Z",
    "updated_at": "2025-08-22T03:54:57.000000Z",
    "active": true,
    "position": 1
}

After that, my code to deserialize the JSON above stop to working and the var Valid is everytime false and the var CatalogModel dont have any other properties filled.

I did a search on forum, but I didnt find any similar case.

Is it the expected behavior? Have in the mormot2 any way to deserialize automatically a JSON and just ignore the properties that is not existing in the application class? Or in that case I will need to do the desearialization manually, property by property?

Any help is welcome.

Thank you.

#4 mORMot 2 » Collate for case insensitive in Firebird » 2025-06-07 02:28:06

StraighFree
Replies: 1

Hello,

I’m studying the mORMot2 and its really great framework.

I created a small application that use a external database in Firebird to test the functionality and all works like a charm. Now, I need to implement the search in Firebird using case insensitive.

Could you please help me to understand how achieve that?

Thank you for amazing framework.

Board footer

Powered by FluxBB