danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render with ObjectDict() for a Single Object with TMVCSerializationAction

sonjli opened this issue · comments

Hello.
I don't know if this is a real issue so I explain my case:

I have a EntityProcessor that have to add some HATEOAS links to a Entity
Case 1: In GetEntites I do:

var
   lEntities: TObjectList<TMacchinaUser>;
...
Renderer.Render(ObjectDict().Add('data', lEntities, RicettaEsplosaLink)) 
// RicettaEsplosaLink is a TMVCSerializationAction

Case 2: In GetEntity I do:

var
   lEntities: TMacchinaUser;
...
Renderer.Render(ObjectDict().Add('data', lEntities, RicettaEsplosaLink)) as for GetEntities
// RicettaEsplosaLink is a TMVCSerializationAction

In second case the rendered JSON is WITHOUT the links.

After some debugging I think I found the "problem". I attach the "MVCFramework.Serializer.JsonDataObjects.pas" with my edit at line 573.

I hope this can help.

Eddy
MVCFramework.Serializer.JsonDataObjects.zip

Thank you for your analysis. I'll get into it ASAP.

FYI
I don't use the form Renderer.Render(200, lEntities, RicettaEsplosaLink) (Without ObjectDict()) because i need the "data" object that surrounds the entity.

Thanks
Eddy

Patch integrated (with s small change). Thank you.