Jump to content

Search the Community

Showing results for tags 'serialize'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. I need to serialize and de-serialize different records types. I wrote the following code that works ok only for the serialization and to be honest, I have not tested having records with class objects. The opposite, the de-serialization gives me an error " Internal: Cannot instantiate type .... " when calling the TJson.JsonToObject. I believe it has to do with the initialization of the new object but I can not understand the problem Any ideas? Thank you in advance The code is: type Trec4Json<T>=class private fbv:T; public class Function rec2J(a: T):string; class Function J2rec(const a: string; var c:T):boolean; property bv:T read fbv write fbv; end; implementation uses rest.json; { Trec4Json<T> } class function Trec4Json<T>.rec2J(a: T): string; // Record to Json String var b: Trec4Json<T>; begin b := Trec4Json<T>.create; b.bv := a; try result := TJson.ObjectToJsonString(b); finally b.free; end; end; class function Trec4Json<T>.J2rec(const a: string; var c: T): boolean; // Json String to Record var b: Trec4Json<T>; begin try b := TJson.JsonToObject < Trec4Json < T >> (a); c := b.bv; b.free; result := true; except result := false; end; end;
×