From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: GNATCOLL JSON Parsing Date: Mon, 26 Nov 2018 21:32:34 +0100 Organization: A noiseless patient Spider Message-ID: References: <9524b3ee-476f-4af6-ab83-b15a6c2a417c@googlegroups.com> <4d7da2e7-ae4f-40da-a6af-e46db135e807@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 26 Nov 2018 20:32:34 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="b5e034ca81f319f1d125aff8c8719de4"; logging-data="6345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1839hZQbtEmQj9gqSplrOUF" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:F+esmn8I9r4gYePvFD9LPk44H3E= In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:54905 Date: 2018-11-26T21:32:34+01:00 List-Id: On 2018-11-26 19:01, Simon Wright wrote: > eduardsapotski@gmail.com writes: > >> Yes, most likely a problem with ssl. I build AWS separately with >> support openssl. Everything is working. Hmm I though I had build mine with ssl. Never mind it works with http. However I am a bit uncertain on the validity of the JSON served by the server. IF it is an array, it should be enclosed by '[' ']' So - I added that , and a name for it, and then it works. Still, my version gives it all as ONE element, so you need to fiddle a bit with the JSON syntax. I looked at it and it looks right, but only one element. code below with Aws; with Aws.Client; with Aws.Response; with Ada.Text_IO; use Ada.Text_IO; with Gnatcoll.Json; use Gnatcoll.Json; procedure Test_Json is Json_Reply : Json_Value := Create; Json_Item : Json_Value := Create; Json_Result_Array : Json_Array := Empty_Array; Aws_Reply : Aws.Response.Data; begin Aws_Reply := Aws.Client.Get (Url => "http://api.exmo.com/v1/pair_settings"); -- Put_Line ("{" & '"' & "list" & '"' & ":[" & Aws.Response.Message_Body(Aws_Reply) & "]}"); Json_Reply := Read (Strm => "{" & '"' & "list" & '"' & ":[" & Aws.Response.Message_Body(Aws_Reply) & "]}", Filename => ""); if Json_Reply.Has_Field("list") then Json_Result_Array := Json_Reply.Get("list"); end if; Put_Line ("Length(Json_Result_Array)" & Length(Json_Result_Array)'img); if Length(Json_Result_Array) > 0 then for I in 1 .. Length(Json_Result_Array) loop Json_Item := Get(Json_Result_Array,I); Put_Line( Kind(Json_Item)'img ); end loop; end if; end Test_Json; -- -- Björn