Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/JSON/Crystal/json-1.crystal
Normal file
14
Task/JSON/Crystal/json-1.crystal
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require "json_mapping"
|
||||
|
||||
class Foo
|
||||
JSON.mapping(
|
||||
num: Int64,
|
||||
array: Array(String),
|
||||
)
|
||||
end
|
||||
|
||||
def json
|
||||
foo = Foo.from_json(%({"num": 1, "array": ["a", "b"]}))
|
||||
puts("#{foo.num} #{foo.array}")
|
||||
puts(foo.to_json)
|
||||
end
|
||||
14
Task/JSON/Crystal/json-2.crystal
Normal file
14
Task/JSON/Crystal/json-2.crystal
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require "json"
|
||||
|
||||
class Foo
|
||||
include JSON::Serializable
|
||||
|
||||
property num : Int64
|
||||
property array : Array(String)
|
||||
end
|
||||
|
||||
def json
|
||||
foo = Foo.from_json(%({"num": 1, "array": ["a", "b"]}))
|
||||
puts("#{foo.num} #{foo.array}")
|
||||
puts(foo.to_json)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue