Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-02

Adding items in a json object and then save to file

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

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.

Find attatched a demo application.

Thx.

Silvio Cl?cio ==================================== Site - <silvioprog.com.br> LazSolutions - <code.google.com/p/lazsolutions> ==================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: json.zip Type: application/zip Size: 1618 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120207/a6f9ba16/attachment.zip>

Reply by email

Unknown author
to silvioprog
silvioprog wrote 6 lines
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.

Reply by email

silvioprog
to Unknown author

2012/2/7 :

Show quoted text 28 lines
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.

His was exactly answer I wanted. Thank you guy! :)

Silvio Cl?cio ==================================== Site - <silvioprog.com.br> LazSolutions - <code.google.com/p/lazsolutions> ====================================

Reply by email