comp.lang.ada
 help / color / mirror / Atom feed
From: Per Sandberg <persan.sandberg@gmail.com>
Subject: Re: GNATCOLL JSON Parsing
Date: Fri, 8 Jun 2018 05:00:27 -0700 (PDT)
Date: 2018-06-08T05:00:27-07:00	[thread overview]
Message-ID: <14be5c44-a9d8-42c8-a9fd-7beae8414433@googlegroups.com> (raw)
In-Reply-To: <9524b3ee-476f-4af6-ab83-b15a6c2a417c@googlegroups.com>

On Friday, June 8, 2018 at 7:52:56 AM UTC+2, eduards...@gmail.com wrote:
> I try understand parsing JSON in Ada. 
> 
> For example:
> Have web-api that gives simple JSON: http://api.exmo.com/v1/trades/?pair=BTC_USD&limit=10
> 
> I need to save this data to database.
> Created type:
> 
>    type Money is delta 0.00000001 range 0.0 .. 9_999_999_999.9;
>    type UTC_Date is range 1_500_000_000 .. 3_000_000_000;
> 
>    type Trade is record
> 
>       Trade_Id   : Integer;
>       Pair       : Unbounded_String;
>       Trade_Type : Unbounded_String;
>       Price      : Money;
>       Quantity   : Money;
>       Amount     : Money;
>       Date       : UTC_Date;
>       Saved      : Boolean;
> 
>    end record;
> 
> Created collection:
> 
>     package Vector_Trades is new Ada.Containers.Vectors(Natural, Trade);
> 
>     Trades : Vector_Trades.Vector;
> 
> Receive data:
> 
> JSON : Unbounded_String;
> 
> JSON := To_Unbounded_String(AWS.Response.Message_Body (AWS.Client.Get (URL => "http://api.exmo.com/v1/trades/?pair=BTC_USD&limit=10")));
> 
> What to do next? How to get list of objects from the JSON-text?
> 
> How to save data to database already understood.
> 
> Thanks.

You might find the library
 https://github.com/persan/gnatcoll-json
Usefull it contains JSON suport for most Ada.Containers.* packages and som examples.
/P

  parent reply	other threads:[~2018-06-08 12:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08  5:52 GNATCOLL JSON Parsing eduardsapotski
2018-06-08  9:35 ` Björn Lundin
2018-06-08 10:40 ` eduardsapotski
2018-06-08 12:00 ` Per Sandberg [this message]
2018-06-08 15:19 ` eduardsapotski
2018-06-08 15:26   ` Björn Lundin
2018-12-03 15:02   ` Olivier Henley
2018-12-03 18:06     ` Dmitry A. Kazakov
2018-12-03 18:45       ` Olivier Henley
2018-12-03 20:54         ` Dmitry A. Kazakov
2018-12-03 22:01           ` Olivier Henley
2018-12-03 18:06     ` briot.emmanuel
2018-12-03 19:12       ` Olivier Henley
2018-12-03 19:43         ` briot.emmanuel
2018-12-03 20:48           ` Olivier Henley
2018-12-03 20:56             ` Olivier Henley
2018-12-04  7:25             ` briot.emmanuel
2018-12-04 13:39               ` Olivier Henley
2018-12-04 10:14             ` gautier_niouzes
2018-12-04 13:47               ` Olivier Henley
2018-06-08 15:58 ` eduardsapotski
2018-06-08 16:35 ` eduardsapotski
2018-06-08 17:09   ` Björn Lundin
2018-06-09  4:33   ` gautier_niouzes
2018-11-27  6:22   ` Per Sandberg
2018-06-09  4:37 ` gautier_niouzes
2018-06-09  5:08 ` eduardsapotski
2018-06-09  5:31 ` eduardsapotski
2018-06-12  9:55   ` R Srinivasan
2018-06-09  5:35 ` eduardsapotski
2018-11-26  6:42 ` eduardsapotski
2018-11-26 10:17   ` Björn Lundin
2018-11-26 15:56     ` Simon Wright
2018-11-26 16:11       ` eduardsapotski
2018-11-26 18:01         ` Simon Wright
2018-11-26 20:32           ` Björn Lundin
2018-12-03 18:10   ` Simon Wright
2018-11-26 10:26 ` eduardsapotski
2018-11-26 10:50 ` eduardsapotski
2018-11-26 16:16 ` eduardsapotski
2018-11-27  1:47 ` eduardsapotski
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox