json 2.21.1-java → 3.0.0.rc1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +45 -0
- data/README.md +4 -84
- data/lib/json/common.rb +86 -402
- data/lib/json/ext/generator/state.rb +0 -27
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- data/lib/json/ext.rb +0 -2
- data/lib/json/truffle_ruby/generator.rb +38 -80
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +24 -265
- metadata +2 -18
- data/lib/json/add/bigdecimal.rb +0 -58
- data/lib/json/add/complex.rb +0 -51
- data/lib/json/add/core.rb +0 -13
- data/lib/json/add/date.rb +0 -54
- data/lib/json/add/date_time.rb +0 -67
- data/lib/json/add/exception.rb +0 -49
- data/lib/json/add/ostruct.rb +0 -54
- data/lib/json/add/range.rb +0 -54
- data/lib/json/add/rational.rb +0 -49
- data/lib/json/add/regexp.rb +0 -48
- data/lib/json/add/set.rb +0 -48
- data/lib/json/add/string.rb +0 -35
- data/lib/json/add/struct.rb +0 -52
- data/lib/json/add/symbol.rb +0 -52
- data/lib/json/add/time.rb +0 -52
- data/lib/json/generic_object.rb +0 -67
data/lib/json/generic_object.rb
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
begin
|
|
3
|
-
require 'ostruct'
|
|
4
|
-
rescue LoadError
|
|
5
|
-
warn "JSON::GenericObject requires 'ostruct'. Please install it with `gem install ostruct`."
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
module JSON
|
|
9
|
-
class GenericObject < OpenStruct
|
|
10
|
-
class << self
|
|
11
|
-
alias [] new
|
|
12
|
-
|
|
13
|
-
def json_creatable?
|
|
14
|
-
@json_creatable
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
attr_writer :json_creatable
|
|
18
|
-
|
|
19
|
-
def json_create(data)
|
|
20
|
-
data = data.dup
|
|
21
|
-
data.delete JSON.create_id
|
|
22
|
-
self[data]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def from_hash(object)
|
|
26
|
-
case
|
|
27
|
-
when object.respond_to?(:to_hash)
|
|
28
|
-
result = new
|
|
29
|
-
object.to_hash.each do |key, value|
|
|
30
|
-
result[key] = from_hash(value)
|
|
31
|
-
end
|
|
32
|
-
result
|
|
33
|
-
when object.respond_to?(:to_ary)
|
|
34
|
-
object.to_ary.map { |a| from_hash(a) }
|
|
35
|
-
else
|
|
36
|
-
object
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def load(source, proc = nil, opts = {})
|
|
41
|
-
result = ::JSON.load(source, proc, opts.merge(:object_class => self))
|
|
42
|
-
result.nil? ? new : result
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def dump(obj, *args)
|
|
46
|
-
::JSON.dump(obj, *args)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
self.json_creatable = false
|
|
50
|
-
|
|
51
|
-
def to_hash
|
|
52
|
-
table
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def |(other)
|
|
56
|
-
self.class[other.to_hash.merge(to_hash)]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def as_json(*)
|
|
60
|
-
{ JSON.create_id => self.class.name }.merge to_hash
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def to_json(*a)
|
|
64
|
-
as_json.to_json(*a)
|
|
65
|
-
end
|
|
66
|
-
end if defined?(::OpenStruct)
|
|
67
|
-
end
|