[Lazarus] Adding items in a json object and then save to file

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue Feb 7 16:09:20 CET 2012



On Tue, 7 Feb 2012, silvioprog wrote:

> Hellow guys, good afternoon. :)
>
> I'm tried to add items in a json object, and I tryied to save it in a
> file using stream. My doubt is: do I need to do everything manually?
> Or has json a native feature to save it in file? I really could not
> find it.

You must do it manually.

It's really simple.

Var
   S : TJSONStringType;

begin

With TFileStream.Create(MyFileName,fmCreate)
   try
     S:=MyObject.AsJSON;
     WriteBuffer(S[1],Length(S));
   finally
     Free;
   end;

But maybe a method to do this would not be bad.

Michael.




More information about the Lazarus mailing list