Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,41 +0,0 @@
|
|||
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;
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
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;
|
||||
|
|
@ -11,4 +11,4 @@ object: #[
|
|||
married: false
|
||||
]
|
||||
|
||||
print write.json ø object
|
||||
print write.json object ø
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
put$(jsn$(get$("input.json",JSN)),"output.JSN,NEW)
|
||||
put$(jsn$(get$("input.json",JSN)),"output.JSN",NEW)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import extensions;
|
||||
import extensions'dynamic;
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
var json := "{ ""foo"": 1, ""bar"": [10, ""apples""] }";
|
||||
|
||||
var o := json.fromJson();
|
||||
|
||||
console.printLine("json.foo=",o.foo);
|
||||
console.printLine("json.bar=",o.bar)
|
||||
Console.printLine("json.foo=",o.foo);
|
||||
Console.printLine("json.bar=",o.bar)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
(require 'cl-lib)
|
||||
|
||||
(cl-assert (fboundp 'json-parse-string))
|
||||
(cl-assert (fboundp 'json-serialize))
|
||||
|
||||
(defvar example "{\"foo\": \"bar\", \"baz\": [1, 2, 3]}")
|
||||
(defvar example-object '((foo . "bar") (baz . [1 2 3])))
|
||||
|
||||
;; decoding
|
||||
(json-parse-string example) ;=> #s(hash-table [...]))
|
||||
;; using json.el-style options
|
||||
(json-parse-string example :object-type 'alist :null-object nil :false-object :json-false)
|
||||
;;=> ((foo . "bar") (baz . [1 2 3]))
|
||||
;; using plists for objects
|
||||
(json-parse-string example :object-type 'plist) ;=> (:foo "bar" :baz [1 2 3])
|
||||
|
||||
;; encoding
|
||||
(json-serialize example-object) ;=> "{\"foo\":\"bar\",\"baz\":[1,2,3]}"
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
(require 'json)
|
||||
|
||||
(defvar example "{\"foo\": \"bar\", \"baz\": [1, 2, 3]}")
|
||||
(defvar example-object '((foo . "bar") (baz . [1 2 3])))
|
||||
|
||||
;; decoding
|
||||
(json-read-from-string example) ;=> ((foo . "bar") (baz . [1 2 3]))
|
||||
;; using plists for objects
|
||||
(let ((json-object-type 'plist))
|
||||
(json-read-from-string)) ;=> (:foo "bar" :baz [1 2 3])
|
||||
;; using hash tables for objects
|
||||
(let ((json-object-type 'hash-table))
|
||||
(json-read-from-string example)) ;=> #<hash-table equal 2/65 0x1563c39805fb>
|
||||
|
||||
;; encoding
|
||||
(json-encode example-object) ;=> "{\"foo\":\"bar\",\"baz\":[1,2,3]}"
|
||||
;; pretty-printing
|
||||
(let ((json-encoding-pretty-print t))
|
||||
(message "%s" (json-encode example-object)))
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
:- %say
|
||||
|= [^ [in=@tas ~] ~]
|
||||
:- %noun
|
||||
=+ obj=(need (poja in)) :: try parse to json
|
||||
=+ typ=$:(name=@tas age=@ud) :: datastructure
|
||||
=+ spec=(ot name/so age/ni ~):jo :: parsing spec
|
||||
?. ?=([%o *] obj) :: isnt an object?
|
||||
~
|
||||
=+ ^= o
|
||||
%. %. (spec obj) :: parse with spec
|
||||
need :: panic if failed
|
||||
,typ :: cast to type
|
||||
=. age.o +(age.o) :: increment its age...
|
||||
%: crip %: pojo :: pretty-print result
|
||||
(jobe [%name s/name.o] [%age n/(crip <age.o>)] ~) :: convert back to json
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
(var object {:a 1 :b "Hello, world!" [1 2 3] :c}
|
||||
serialised (to-json object)
|
||||
deserialised (from-json serialised))
|
||||
|
||||
(print "Object: " object)
|
||||
(print "Serialised: " serialised)
|
||||
(str "Deserialised: " deserialised)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# JSON input is being stored in ordered hashtable.
|
||||
# Ordered hashtable is available in PowerShell v3 and higher.
|
||||
[ordered]@{ "foo"= 1; "bar"= 10, "apples" } | ConvertTo-Json
|
||||
|
||||
# ConvertFrom-Json converts a JSON-formatted string to a custom object.
|
||||
# If you use the Invoke-RestMethod cmdlet there is not need for the ConvertFrom-Json cmdlet
|
||||
Invoke-WebRequest -Uri "http://date.jsontest.com" | ConvertFrom-Json
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"foo": 1,
|
||||
"bar": [
|
||||
10,
|
||||
"apples"
|
||||
]
|
||||
}
|
||||
|
||||
time milliseconds_since_epoch date
|
||||
---- ------------------------ ----
|
||||
12:25:25 PM 1414326325923 10-26-2014
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
json-str: {{"menu": {
|
||||
"id": "file",
|
||||
"string": "File:",
|
||||
"number": -3,
|
||||
"boolean": true,
|
||||
"boolean2": false,
|
||||
"null": null,
|
||||
"array": [1, 0.13, null, true, false, "\t\r\n"],
|
||||
"empty-string": ""
|
||||
}
|
||||
}}
|
||||
|
||||
reb: json-to-rebol json-str
|
||||
str: rebol-to-json reb
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
json-str: {{"menu": {
|
||||
"id": "file",
|
||||
"string": "File:",
|
||||
"number": -3,
|
||||
"boolean": true,
|
||||
"boolean2": false,
|
||||
"null": null,
|
||||
"array": [1, 0.13, null, true, false, "\t\r\n"],
|
||||
"empty-string": ""
|
||||
}
|
||||
}}
|
||||
import json ;; just in case it's not yet imported
|
||||
probe reb: decode 'json json-str
|
||||
probe str: encode 'json reb ;; outputs without any indentation
|
||||
;; Validate that re-encoded JSON is same
|
||||
probe equal? reb decode 'json str
|
||||
Loading…
Add table
Add a link
Reference in a new issue