Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

41
Task/JSON/Ada/json-1.ada Normal file
View file

@ -0,0 +1,41 @@
with Ada.Text_IO;
with GNATCOLL.JSON;
procedure JSON_Test is
use Ada.Text_IO;
use GNATCOLL.JSON;
JSON_String : constant String := "{""name"":""Pingu"",""born"":1986}";
Penguin : JSON_Value := Create_Object;
Parents : JSON_Array;
begin
Penguin.Set_Field (Field_Name => "name",
Field => "Linux");
Penguin.Set_Field (Field_Name => "born",
Field => 1992);
Append (Parents, Create ("Linus Torvalds"));
Append (Parents, Create ("Alan Cox"));
Append (Parents, Create ("Greg Kroah-Hartman"));
Penguin.Set_Field (Field_Name => "parents",
Field => Parents);
Put_Line (Penguin.Write);
Penguin := Read (JSON_String, "json.errors");
Penguin.Set_Field (Field_Name => "born",
Field => 1986);
Parents := Empty_Array;
Append (Parents, Create ("Otmar Gutmann"));
Append (Parents, Create ("Silvio Mazzola"));
Penguin.Set_Field (Field_Name => "parents",
Field => Parents);
Put_Line (Penguin.Write);
end JSON_Test;

41
Task/JSON/Ada/json-2.ada Normal file
View file

@ -0,0 +1,41 @@
with Ada.Wide_Wide_Text_IO; use Ada.Wide_Wide_Text_IO;
with League.JSON.Arrays; use League.JSON.Arrays;
with League.JSON.Documents; use League.JSON.Documents;
with League.JSON.Objects; use League.JSON.Objects;
with League.JSON.Values; use League.JSON.Values;
with League.Strings; use League.Strings;
procedure Main is
function "+" (Item : Wide_Wide_String) return Universal_String
renames To_Universal_String;
JSON_String : constant Universal_String
:= +"{""name"":""Pingu"",""born"":1986}";
Penguin : JSON_Object;
Parents : JSON_Array;
begin
Penguin.Insert (+"name", To_JSON_Value (+"Linux"));
Penguin.Insert (+"born", To_JSON_Value (1992));
Parents.Append (To_JSON_Value (+"Linus Torvalds"));
Parents.Append (To_JSON_Value (+"Alan Cox"));
Parents.Append (To_JSON_Value (+"Greg Kroah-Hartman"));
Penguin.Insert (+"parents", To_JSON_Value (Parents));
Put_Line (To_JSON_Document (Penguin).To_JSON.To_Wide_Wide_String);
Penguin := From_JSON (JSON_String).To_JSON_Object;
Parents := Empty_JSON_Array;
Parents.Append (To_JSON_Value (+"Otmar Gutmann"));
Parents.Append (To_JSON_Value (+"Silvio Mazzola"));
Penguin.Insert (+"parents", To_JSON_Value (Parents));
Put_Line (To_JSON_Document (Penguin).To_JSON.To_Wide_Wide_String);
end Main;