Delphi Serialize
An updated version of the JSON Serializer library is available in article JSON object serializer for Delphi The updated library is completely Open Source. You can serialize and deserialize arrays and unions of objects of different types, deserialize inherited objects, serialize empty strings and many more. JSON (JavaScript. Update: the current version of the library will use the enhanced RTTI available since Delphi 2010 to serialize as JSON records and dynamic array contents.
Code: class procedure TBaseService.SetJSONResponse(Data: T); var ctx: TSuperRttiContext; s: string; SO:ISuperObject; begin ctx:= TSuperRttiContext.Create; try s:=ctx.AsJson(Data).AsString; RequestContext.Response.Content:=s; RequestContext.Response.ContentType:='application/json'; finally Ctx.Free; end; end; That does not build in Lazarus, the relevant bits in SuperObject rely on Delphi Units Generics.Collections and RTTI, porting that would require more effort and investigations than I want to put into SuperObject. So I thought of replacing this with fpjsonrtti from Free Pascal. The problem here is that I cannot write a single method that takes an Object (any descendant of course) AND a dynamic array of any type. I thought of maybe wrapping my array into simple objects and passing those because apparently fpjsonrtti can handle array members in objects. Any ideas on that? Any other suggestions?
Thank you for reading this far, and devoting brain-cycles to it, Marian.
Hi, I have very low to no knowledge of JSON. So, I maybe asking my question wrongly here. Hope it will be understandable. There is this C# application with code available to me which uses a C# DLL. Application is communicating with a POS device using that DLL.
I am writing a Delphi application which uses that same C# DLL. I see that at some point C# application using JsonConvert. Adolph Coors In The Brewing Industry Pdf Converter. SerializeObject() and JsonConvert.DeserializeObject() functions, when I check the code. Sample lines from C# code is as follows.