From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: problems parse (large) json file with gnatcoll.json
Date: Mon, 18 Apr 2016 21:05:01 +0200
Date: 2016-04-18T21:05:01+02:00 [thread overview]
Message-ID: <nf3bd5$t6m$1@dont-email.me> (raw)
In-Reply-To: <nf3a5n$ob5$1@dont-email.me>
On 2016-04-18 20:51, Jeffrey R. Carter wrote:
> I doubt the subtype declaration gives you Storage_Error. It should be if
> you declare an object of the subtype:
Of course you are correct.
I wonder how I misread the stacktrace that much.
Anyway your tip paid off.
> You can probably get around this by declaring an access type:
The loading function now looks like
function Load_File(Filename : in String) return String is
use Ada.Directories;
File_Size : constant Natural := Natural (Size (Filename));
subtype JSON_String is String (1 .. File_Size);
type String_Ptr is access JSON_String;
Content : constant String_Ptr := new JSON_String;
package File_IO is new Ada.Direct_IO(JSON_String);
File : File_IO.File_Type;
begin
File_IO.Open (File => File, Mode => File_IO.In_File,
Name => Filename);
File_IO.Read (File => File, Item => Content.all);
File_IO.Close(File => File);
return Content.all;
end Load_File;
--------------------------
and it works. Thanks. (I'll fix the leak later on)
The Load_File function is from
http://wiki.ada-dk.org/index.php/Handling_JSON_Using_GNATColl
--
Björn
next prev parent reply other threads:[~2016-04-18 19:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 18:21 problems parse (large) json file with gnatcoll.json Björn Lundin
2016-04-18 18:51 ` Jeffrey R. Carter
2016-04-18 19:05 ` Björn Lundin [this message]
2016-04-19 19:48 ` Shark8
2016-04-20 7:50 ` AdaMagica
2016-04-21 8:44 ` Björn Lundin
2016-04-25 10:38 ` briot.emmanuel
2016-04-25 15:12 ` Björn Lundin
2016-04-18 18:59 ` joakimds
2016-04-18 19:23 ` Björn Lundin
2016-04-19 8:17 ` Jacob Sparre Andersen
2016-04-19 9:14 ` Björn Lundin
2016-04-19 9:56 ` gautier_niouzes
2016-04-19 12:49 ` G.B.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox