new files

This commit is contained in:
Ingy döt Net 2013-04-10 12:38:42 -07:00
parent 3af7344581
commit 86c034bb8b
1364 changed files with 21352 additions and 0 deletions

41
Task/JSON/Ada/json.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;

25
Task/JSON/Go/json-1.go Normal file
View file

@ -0,0 +1,25 @@
package main
import "encoding/json"
import "fmt"
func main() {
var data interface{}
err := json.Unmarshal([]byte(`{"foo":1, "bar":[10, "apples"]}`), &data)
if err == nil {
fmt.Println(data)
} else {
fmt.Println(err)
}
sample := map[string]interface{}{
"blue": []interface{}{1, 2},
"ocean": "water",
}
json_string, err := json.Marshal(sample)
if err == nil {
fmt.Println(string(json_string))
} else {
fmt.Println(err)
}
}

View file

@ -0,0 +1,4 @@
var data = JSON.parse('{ "foo": 1, "bar": [10, "apples"] }');
var sample = { "blue": [1,2], "ocean": "water" };
var json_string = JSON.stringify(sample);

View file

@ -0,0 +1,10 @@
>>> import json
>>> data = json.loads('{ "foo": 1, "bar": [10, "apples"] }')
>>> sample = { "blue": [1,2], "ocean": "water" }
>>> json_string = json.dumps(sample)
>>> json_string
'{"blue": [1, 2], "ocean": "water"}'
>>> sample
{'blue': [1, 2], 'ocean': 'water'}
>>> data
{'foo': 1, 'bar': [10, 'apples']}

3
Task/JSON/R/json-1.r Normal file
View file

@ -0,0 +1,3 @@
library(rjson)
data <- fromJSON('{ "foo": 1, "bar": [10, "apples"] }')
data

5
Task/JSON/Tcl/json-1.tcl Normal file
View file

@ -0,0 +1,5 @@
package require json
set sample {{ "foo": 1, "bar": [10, "apples"] }}
set parsed [json::json2dict $sample]
puts $parsed