acts-as-messageable 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +8 -0
  3. data/.github/workflows/test.yml +152 -0
  4. data/.rubocop.yml +14 -1
  5. data/.rubocop_todo.yml +49 -7
  6. data/.ruby-version +1 -0
  7. data/Appraisals +11 -0
  8. data/Dockerfile +2 -1
  9. data/Gemfile +19 -13
  10. data/Gemfile.lock +186 -97
  11. data/README.md +2 -3
  12. data/Rakefile +6 -1
  13. data/VERSION +1 -1
  14. data/acts-as-messageable.gemspec +193 -40
  15. data/bin/tapioca +29 -0
  16. data/docker-compose.yml +82 -71
  17. data/gemfiles/rails_3.2.gemfile +14 -9
  18. data/gemfiles/rails_4.2.gemfile +14 -9
  19. data/gemfiles/rails_5.2.gemfile +14 -9
  20. data/gemfiles/rails_6.0.gemfile +14 -9
  21. data/gemfiles/rails_7.0.gemfile +29 -0
  22. data/gemfiles/rails_master.gemfile +15 -9
  23. data/lib/acts-as-messageable.rb +1 -0
  24. data/lib/acts_as_messageable/message.rb +62 -5
  25. data/lib/acts_as_messageable/model.rb +71 -20
  26. data/lib/acts_as_messageable/rails3.rb +27 -2
  27. data/lib/acts_as_messageable/rails4.rb +31 -4
  28. data/lib/acts_as_messageable/rails6.rb +34 -2
  29. data/lib/acts_as_messageable/railtie.rb +1 -0
  30. data/lib/acts_as_messageable/relation.rb +18 -2
  31. data/lib/acts_as_messageable/scopes.rb +11 -0
  32. data/lib/acts_as_messageable.rb +18 -0
  33. data/lib/generators/acts_as_messageable/migration/migration_generator.rb +4 -0
  34. data/lib/generators/acts_as_messageable/migration/templates/migration.rb +1 -0
  35. data/lib/generators/acts_as_messageable/migration/templates/migration_indexes.rb +1 -0
  36. data/lib/generators/acts_as_messageable/migration/templates/migration_opened_as_datetime.rb +1 -0
  37. data/lib/generators/acts_as_messageable/migration/templates/migration_permanent.rb +1 -0
  38. data/sorbet/config +4 -0
  39. data/sorbet/rbi/annotations/actionpack.rbi +428 -0
  40. data/sorbet/rbi/annotations/actionview.rbi +77 -0
  41. data/sorbet/rbi/annotations/activerecord.rbi +18 -0
  42. data/sorbet/rbi/annotations/activesupport.rbi +52 -0
  43. data/sorbet/rbi/annotations/faraday.rbi +17 -0
  44. data/sorbet/rbi/annotations/railties.rbi +58 -0
  45. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  46. data/sorbet/rbi/dsl/abstract_controller/caching/fragments.rbi +23 -0
  47. data/sorbet/rbi/dsl/abstract_controller/caching.rbi +30 -0
  48. data/sorbet/rbi/dsl/abstract_controller/callbacks.rbi +23 -0
  49. data/sorbet/rbi/dsl/abstract_controller/helpers.rbi +23 -0
  50. data/sorbet/rbi/dsl/abstract_controller/rendering.rbi +9 -0
  51. data/sorbet/rbi/dsl/abstract_controller/url_for.rbi +23 -0
  52. data/sorbet/rbi/dsl/action_controller/caching.rbi +29 -0
  53. data/sorbet/rbi/dsl/action_controller/conditional_get.rbi +23 -0
  54. data/sorbet/rbi/dsl/action_controller/content_security_policy.rbi +31 -0
  55. data/sorbet/rbi/dsl/action_controller/data_streaming.rbi +9 -0
  56. data/sorbet/rbi/dsl/action_controller/etag_with_flash.rbi +24 -0
  57. data/sorbet/rbi/dsl/action_controller/etag_with_template_digest.rbi +30 -0
  58. data/sorbet/rbi/dsl/action_controller/flash.rbi +19 -0
  59. data/sorbet/rbi/dsl/action_controller/form_builder.rbi +19 -0
  60. data/sorbet/rbi/dsl/action_controller/helpers.rbi +36 -0
  61. data/sorbet/rbi/dsl/action_controller/params_wrapper.rbi +23 -0
  62. data/sorbet/rbi/dsl/action_controller/redirecting.rbi +24 -0
  63. data/sorbet/rbi/dsl/action_controller/renderers/all.rbi +24 -0
  64. data/sorbet/rbi/dsl/action_controller/renderers.rbi +23 -0
  65. data/sorbet/rbi/dsl/action_controller/request_forgery_protection.rbi +31 -0
  66. data/sorbet/rbi/dsl/action_controller/rescue.rbi +24 -0
  67. data/sorbet/rbi/dsl/action_controller/test_case/behavior.rbi +24 -0
  68. data/sorbet/rbi/dsl/action_controller/url_for.rbi +24 -0
  69. data/sorbet/rbi/dsl/action_dispatch/routing/url_for.rbi +23 -0
  70. data/sorbet/rbi/dsl/action_view/helpers/form_helper.rbi +10 -0
  71. data/sorbet/rbi/dsl/action_view/helpers/form_tag_helper.rbi +10 -0
  72. data/sorbet/rbi/dsl/action_view/helpers/text_helper.rbi +9 -0
  73. data/sorbet/rbi/dsl/action_view/helpers.rbi +10 -0
  74. data/sorbet/rbi/dsl/action_view/layouts.rbi +24 -0
  75. data/sorbet/rbi/dsl/action_view/rendering.rbi +9 -0
  76. data/sorbet/rbi/dsl/active_model/attribute_methods.rbi +27 -0
  77. data/sorbet/rbi/dsl/active_model/attributes.rbi +34 -0
  78. data/sorbet/rbi/dsl/active_model/dirty.rbi +28 -0
  79. data/sorbet/rbi/dsl/active_model/serializers/json.rbi +22 -0
  80. data/sorbet/rbi/dsl/active_model/validations/callbacks.rbi +22 -0
  81. data/sorbet/rbi/dsl/active_model/validations.rbi +27 -0
  82. data/sorbet/rbi/dsl/active_record/attribute_methods/dirty.rbi +38 -0
  83. data/sorbet/rbi/dsl/active_record/attribute_methods/time_zone_conversion.rbi +32 -0
  84. data/sorbet/rbi/dsl/active_record/attribute_methods.rbi +53 -0
  85. data/sorbet/rbi/dsl/active_record/attributes.rbi +19 -0
  86. data/sorbet/rbi/dsl/active_record/callbacks.rbi +22 -0
  87. data/sorbet/rbi/dsl/active_record/core.rbi +55 -0
  88. data/sorbet/rbi/dsl/active_record/encryption/encryptable_record.rbi +23 -0
  89. data/sorbet/rbi/dsl/active_record/inheritance.rbi +27 -0
  90. data/sorbet/rbi/dsl/active_record/integration.rbi +32 -0
  91. data/sorbet/rbi/dsl/active_record/locking/optimistic.rbi +22 -0
  92. data/sorbet/rbi/dsl/active_record/model_schema.rbi +52 -0
  93. data/sorbet/rbi/dsl/active_record/nested_attributes.rbi +22 -0
  94. data/sorbet/rbi/dsl/active_record/readonly_attributes.rbi +19 -0
  95. data/sorbet/rbi/dsl/active_record/reflection.rbi +32 -0
  96. data/sorbet/rbi/dsl/active_record/scoping/default.rbi +23 -0
  97. data/sorbet/rbi/dsl/active_record/scoping.rbi +23 -0
  98. data/sorbet/rbi/dsl/active_record/serialization.rbi +22 -0
  99. data/sorbet/rbi/dsl/active_record/signed_id.rbi +22 -0
  100. data/sorbet/rbi/dsl/active_record/test_fixtures.rbi +58 -0
  101. data/sorbet/rbi/dsl/active_record/timestamp.rbi +23 -0
  102. data/sorbet/rbi/dsl/active_record/validations.rbi +28 -0
  103. data/sorbet/rbi/dsl/active_support/actionable_error.rbi +23 -0
  104. data/sorbet/rbi/dsl/active_support/callbacks.rbi +22 -0
  105. data/sorbet/rbi/dsl/active_support/rescuable.rbi +23 -0
  106. data/sorbet/rbi/dsl/active_support/testing/file_fixtures.rbi +22 -0
  107. data/sorbet/rbi/gems/actionpack@7.0.4.3.rbi +19265 -0
  108. data/sorbet/rbi/gems/actionview@7.0.4.3.rbi +15482 -0
  109. data/sorbet/rbi/gems/activemodel@7.0.4.3.rbi +6025 -0
  110. data/sorbet/rbi/gems/activerecord@7.0.4.3.rbi +37852 -0
  111. data/sorbet/rbi/gems/activesupport@7.0.4.3.rbi +18788 -0
  112. data/sorbet/rbi/gems/addressable@2.4.0.rbi +8 -0
  113. data/sorbet/rbi/gems/appraisal@2.4.1.rbi +584 -0
  114. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  115. data/sorbet/rbi/gems/builder@3.2.4.rbi +8 -0
  116. data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
  117. data/sorbet/rbi/gems/commander@4.6.0.rbi +8 -0
  118. data/sorbet/rbi/gems/concurrent-ruby@1.2.2.rbi +11545 -0
  119. data/sorbet/rbi/gems/coveralls_reborn@0.27.0.rbi +8 -0
  120. data/sorbet/rbi/gems/crass@1.0.6.rbi +622 -0
  121. data/sorbet/rbi/gems/descendants_tracker@0.0.4.rbi +8 -0
  122. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1079 -0
  123. data/sorbet/rbi/gems/docile@1.4.0.rbi +8 -0
  124. data/sorbet/rbi/gems/erubi@1.12.0.rbi +146 -0
  125. data/sorbet/rbi/gems/faraday@0.9.2.rbi +964 -0
  126. data/sorbet/rbi/gems/git@1.11.0.rbi +2700 -0
  127. data/sorbet/rbi/gems/github_api@0.16.0.rbi +8 -0
  128. data/sorbet/rbi/gems/hashie@5.0.0.rbi +8 -0
  129. data/sorbet/rbi/gems/highline@2.0.3.rbi +8 -0
  130. data/sorbet/rbi/gems/i18n@1.12.0.rbi +2296 -0
  131. data/sorbet/rbi/gems/jeweler@2.3.9.rbi +1591 -0
  132. data/sorbet/rbi/gems/json@2.6.3.rbi +1541 -0
  133. data/sorbet/rbi/gems/jwt@2.5.0.rbi +8 -0
  134. data/sorbet/rbi/gems/loofah@2.19.1.rbi +904 -0
  135. data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
  136. data/sorbet/rbi/gems/mime-types@2.99.3.rbi +8 -0
  137. data/sorbet/rbi/gems/minitest@5.18.0.rbi +1491 -0
  138. data/sorbet/rbi/gems/multi_json@1.15.0.rbi +8 -0
  139. data/sorbet/rbi/gems/multi_xml@0.6.0.rbi +8 -0
  140. data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +8 -0
  141. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  142. data/sorbet/rbi/gems/nokogiri@1.14.2.rbi +7244 -0
  143. data/sorbet/rbi/gems/oauth2@1.4.8.rbi +8 -0
  144. data/sorbet/rbi/gems/parallel@1.22.1.rbi +277 -0
  145. data/sorbet/rbi/gems/pg@1.4.6.rbi +2574 -0
  146. data/sorbet/rbi/gems/polyfill@1.9.0.rbi +8 -0
  147. data/sorbet/rbi/gems/pry@0.14.2.rbi +10081 -0
  148. data/sorbet/rbi/gems/psych@4.0.6.rbi +1819 -0
  149. data/sorbet/rbi/gems/racc@1.6.2.rbi +155 -0
  150. data/sorbet/rbi/gems/rack-test@2.0.2.rbi +943 -0
  151. data/sorbet/rbi/gems/rack@2.2.6.4.rbi +5659 -0
  152. data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +455 -0
  153. data/sorbet/rbi/gems/rails-html-sanitizer@1.5.0.rbi +685 -0
  154. data/sorbet/rbi/gems/railties@7.0.4.3.rbi +4553 -0
  155. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +8 -0
  156. data/sorbet/rbi/gems/rake@13.0.6.rbi +2959 -0
  157. data/sorbet/rbi/gems/rbi@0.0.16.rbi +3008 -0
  158. data/sorbet/rbi/gems/rbs@2.8.0.rbi +8 -0
  159. data/sorbet/rbi/gems/rchardet@1.8.0.rbi +1078 -0
  160. data/sorbet/rbi/gems/rdoc@6.5.0.rbi +12441 -0
  161. data/sorbet/rbi/gems/regexp_parser@2.7.0.rbi +8 -0
  162. data/sorbet/rbi/gems/rexml@3.2.5.rbi +8 -0
  163. data/sorbet/rbi/gems/rspec-core@3.12.0.rbi +10798 -0
  164. data/sorbet/rbi/gems/rspec-expectations@3.12.0.rbi +8090 -0
  165. data/sorbet/rbi/gems/rspec-mocks@3.12.0.rbi +5296 -0
  166. data/sorbet/rbi/gems/rspec-support@3.12.0.rbi +1617 -0
  167. data/sorbet/rbi/gems/rspec@3.12.0.rbi +88 -0
  168. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +8 -0
  169. data/sorbet/rbi/gems/safe_type@1.1.1.rbi +8 -0
  170. data/sorbet/rbi/gems/semver2@3.4.2.rbi +8 -0
  171. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +8 -0
  172. data/sorbet/rbi/gems/simplecov@0.22.0.rbi +8 -0
  173. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +8 -0
  174. data/sorbet/rbi/gems/sorbet-coerce@0.7.0.rbi +8 -0
  175. data/sorbet/rbi/gems/stringio@3.0.2.rbi +8 -0
  176. data/sorbet/rbi/gems/sync@0.5.0.rbi +8 -0
  177. data/sorbet/rbi/gems/term-ansicolor@1.7.1.rbi +8 -0
  178. data/sorbet/rbi/gems/thor@1.2.1.rbi +3956 -0
  179. data/sorbet/rbi/gems/thread_safe@0.3.6.rbi +8 -0
  180. data/sorbet/rbi/gems/timecop@0.9.6.rbi +361 -0
  181. data/sorbet/rbi/gems/tins@1.32.1.rbi +8 -0
  182. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5917 -0
  183. data/sorbet/rbi/gems/unicode-display_width@2.4.2.rbi +8 -0
  184. data/sorbet/rbi/gems/unparser@0.6.7.rbi +4515 -0
  185. data/sorbet/rbi/gems/webrick@1.7.0.rbi +2553 -0
  186. data/sorbet/rbi/gems/yard@0.9.28.rbi +17954 -0
  187. data/sorbet/rbi/gems/zeitwerk@2.6.7.rbi +966 -0
  188. data/sorbet/rbi/models/acts-as-messageable/message.rbi +668 -0
  189. data/sorbet/rbi/models/acts-as-messageable/user.rbi +343 -0
  190. data/sorbet/rbi/rails-rbi/active_record_base.rbi +119 -0
  191. data/sorbet/rbi/rails-rbi/active_record_relation.rbi +180 -0
  192. data/sorbet/rbi/shims/activerecord.rbi +4 -0
  193. data/sorbet/rbi/shims/model.rbi +9 -0
  194. data/sorbet/tapioca/config.yml +10 -0
  195. data/sorbet/tapioca/pre_require.rb +5 -0
  196. data/sorbet/tapioca/require.rb +10 -0
  197. data/spec/acts_as_messageable_spec.rb +7 -4
  198. data/spec/custom_class_spec.rb +1 -0
  199. data/spec/custom_required_spec.rb +8 -4
  200. data/spec/group_messages_spec.rb +1 -0
  201. data/spec/migrations_spec.rb +2 -1
  202. data/spec/spec_helper.rb +19 -9
  203. data/spec/support/admin.rb +3 -0
  204. data/spec/support/custom_message.rb +3 -0
  205. data/spec/support/custom_message_uuid.rb +1 -0
  206. data/spec/support/custom_search_user.rb +3 -0
  207. data/spec/support/men.rb +1 -0
  208. data/spec/support/send_message.rb +8 -1
  209. data/spec/support/table_schema.rb +7 -6
  210. data/spec/support/user.rb +3 -0
  211. data/spec/support/uuid_user.rb +3 -0
  212. data/tasks/types.rake +46 -0
  213. metadata +261 -11
  214. data/.travis.yml +0 -55
@@ -0,0 +1,1541 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `json` gem.
5
+ # Please instead update this file by running `bin/tapioca gem json`.
6
+
7
+ # Extends any Class to include _json_creatable?_ method.
8
+ #
9
+ # source://json//lib/json/common.rb#695
10
+ class Class < ::Module
11
+ # Returns true if this class can be used to create an instance
12
+ # from a serialised JSON string. The class has to implement a class
13
+ # method _json_create_ that expects a hash as first parameter. The hash
14
+ # should include the required data.
15
+ #
16
+ # @return [Boolean]
17
+ #
18
+ # source://json//lib/json/common.rb#700
19
+ def json_creatable?; end
20
+ end
21
+
22
+ # = JavaScript \Object Notation (\JSON)
23
+ #
24
+ # \JSON is a lightweight data-interchange format.
25
+ #
26
+ # A \JSON value is one of the following:
27
+ # - Double-quoted text: <tt>"foo"</tt>.
28
+ # - Number: +1+, +1.0+, +2.0e2+.
29
+ # - Boolean: +true+, +false+.
30
+ # - Null: +null+.
31
+ # - \Array: an ordered list of values, enclosed by square brackets:
32
+ # ["foo", 1, 1.0, 2.0e2, true, false, null]
33
+ #
34
+ # - \Object: a collection of name/value pairs, enclosed by curly braces;
35
+ # each name is double-quoted text;
36
+ # the values may be any \JSON values:
37
+ # {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
38
+ #
39
+ # A \JSON array or object may contain nested arrays, objects, and scalars
40
+ # to any depth:
41
+ # {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
42
+ # [{"foo": 0, "bar": 1}, ["baz", 2]]
43
+ #
44
+ # == Using \Module \JSON
45
+ #
46
+ # To make module \JSON available in your code, begin with:
47
+ # require 'json'
48
+ #
49
+ # All examples here assume that this has been done.
50
+ #
51
+ # === Parsing \JSON
52
+ #
53
+ # You can parse a \String containing \JSON data using
54
+ # either of two methods:
55
+ # - <tt>JSON.parse(source, opts)</tt>
56
+ # - <tt>JSON.parse!(source, opts)</tt>
57
+ #
58
+ # where
59
+ # - +source+ is a Ruby object.
60
+ # - +opts+ is a \Hash object containing options
61
+ # that control both input allowed and output formatting.
62
+ #
63
+ # The difference between the two methods
64
+ # is that JSON.parse! omits some checks
65
+ # and may not be safe for some +source+ data;
66
+ # use it only for data from trusted sources.
67
+ # Use the safer method JSON.parse for less trusted sources.
68
+ #
69
+ # ==== Parsing \JSON Arrays
70
+ #
71
+ # When +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array:
72
+ # json = '["foo", 1, 1.0, 2.0e2, true, false, null]'
73
+ # ruby = JSON.parse(json)
74
+ # ruby # => ["foo", 1, 1.0, 200.0, true, false, nil]
75
+ # ruby.class # => Array
76
+ #
77
+ # The \JSON array may contain nested arrays, objects, and scalars
78
+ # to any depth:
79
+ # json = '[{"foo": 0, "bar": 1}, ["baz", 2]]'
80
+ # JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]]
81
+ #
82
+ # ==== Parsing \JSON \Objects
83
+ #
84
+ # When the source is a \JSON object, JSON.parse by default returns a Ruby \Hash:
85
+ # json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}'
86
+ # ruby = JSON.parse(json)
87
+ # ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil}
88
+ # ruby.class # => Hash
89
+ #
90
+ # The \JSON object may contain nested arrays, objects, and scalars
91
+ # to any depth:
92
+ # json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}'
93
+ # JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]}
94
+ #
95
+ # ==== Parsing \JSON Scalars
96
+ #
97
+ # When the source is a \JSON scalar (not an array or object),
98
+ # JSON.parse returns a Ruby scalar.
99
+ #
100
+ # \String:
101
+ # ruby = JSON.parse('"foo"')
102
+ # ruby # => 'foo'
103
+ # ruby.class # => String
104
+ # \Integer:
105
+ # ruby = JSON.parse('1')
106
+ # ruby # => 1
107
+ # ruby.class # => Integer
108
+ # \Float:
109
+ # ruby = JSON.parse('1.0')
110
+ # ruby # => 1.0
111
+ # ruby.class # => Float
112
+ # ruby = JSON.parse('2.0e2')
113
+ # ruby # => 200
114
+ # ruby.class # => Float
115
+ # Boolean:
116
+ # ruby = JSON.parse('true')
117
+ # ruby # => true
118
+ # ruby.class # => TrueClass
119
+ # ruby = JSON.parse('false')
120
+ # ruby # => false
121
+ # ruby.class # => FalseClass
122
+ # Null:
123
+ # ruby = JSON.parse('null')
124
+ # ruby # => nil
125
+ # ruby.class # => NilClass
126
+ #
127
+ # ==== Parsing Options
128
+ #
129
+ # ====== Input Options
130
+ #
131
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth allowed;
132
+ # defaults to +100+; specify +false+ to disable depth checking.
133
+ #
134
+ # With the default, +false+:
135
+ # source = '[0, [1, [2, [3]]]]'
136
+ # ruby = JSON.parse(source)
137
+ # ruby # => [0, [1, [2, [3]]]]
138
+ # Too deep:
139
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
140
+ # JSON.parse(source, {max_nesting: 1})
141
+ # Bad value:
142
+ # # Raises TypeError (wrong argument type Symbol (expected Fixnum)):
143
+ # JSON.parse(source, {max_nesting: :foo})
144
+ #
145
+ # ---
146
+ #
147
+ # Option +allow_nan+ (boolean) specifies whether to allow
148
+ # NaN, Infinity, and MinusInfinity in +source+;
149
+ # defaults to +false+.
150
+ #
151
+ # With the default, +false+:
152
+ # # Raises JSON::ParserError (225: unexpected token at '[NaN]'):
153
+ # JSON.parse('[NaN]')
154
+ # # Raises JSON::ParserError (232: unexpected token at '[Infinity]'):
155
+ # JSON.parse('[Infinity]')
156
+ # # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'):
157
+ # JSON.parse('[-Infinity]')
158
+ # Allow:
159
+ # source = '[NaN, Infinity, -Infinity]'
160
+ # ruby = JSON.parse(source, {allow_nan: true})
161
+ # ruby # => [NaN, Infinity, -Infinity]
162
+ #
163
+ # ====== Output Options
164
+ #
165
+ # Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
166
+ # should be Symbols;
167
+ # defaults to +false+ (use Strings).
168
+ #
169
+ # With the default, +false+:
170
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
171
+ # ruby = JSON.parse(source)
172
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
173
+ # Use Symbols:
174
+ # ruby = JSON.parse(source, {symbolize_names: true})
175
+ # ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil}
176
+ #
177
+ # ---
178
+ #
179
+ # Option +object_class+ (\Class) specifies the Ruby class to be used
180
+ # for each \JSON object;
181
+ # defaults to \Hash.
182
+ #
183
+ # With the default, \Hash:
184
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
185
+ # ruby = JSON.parse(source)
186
+ # ruby.class # => Hash
187
+ # Use class \OpenStruct:
188
+ # ruby = JSON.parse(source, {object_class: OpenStruct})
189
+ # ruby # => #<OpenStruct a="foo", b=1.0, c=true, d=false, e=nil>
190
+ #
191
+ # ---
192
+ #
193
+ # Option +array_class+ (\Class) specifies the Ruby class to be used
194
+ # for each \JSON array;
195
+ # defaults to \Array.
196
+ #
197
+ # With the default, \Array:
198
+ # source = '["foo", 1.0, true, false, null]'
199
+ # ruby = JSON.parse(source)
200
+ # ruby.class # => Array
201
+ # Use class \Set:
202
+ # ruby = JSON.parse(source, {array_class: Set})
203
+ # ruby # => #<Set: {"foo", 1.0, true, false, nil}>
204
+ #
205
+ # ---
206
+ #
207
+ # Option +create_additions+ (boolean) specifies whether to use \JSON additions in parsing.
208
+ # See {\JSON Additions}[#module-JSON-label-JSON+Additions].
209
+ #
210
+ # === Generating \JSON
211
+ #
212
+ # To generate a Ruby \String containing \JSON data,
213
+ # use method <tt>JSON.generate(source, opts)</tt>, where
214
+ # - +source+ is a Ruby object.
215
+ # - +opts+ is a \Hash object containing options
216
+ # that control both input allowed and output formatting.
217
+ #
218
+ # ==== Generating \JSON from Arrays
219
+ #
220
+ # When the source is a Ruby \Array, JSON.generate returns
221
+ # a \String containing a \JSON array:
222
+ # ruby = [0, 's', :foo]
223
+ # json = JSON.generate(ruby)
224
+ # json # => '[0,"s","foo"]'
225
+ #
226
+ # The Ruby \Array array may contain nested arrays, hashes, and scalars
227
+ # to any depth:
228
+ # ruby = [0, [1, 2], {foo: 3, bar: 4}]
229
+ # json = JSON.generate(ruby)
230
+ # json # => '[0,[1,2],{"foo":3,"bar":4}]'
231
+ #
232
+ # ==== Generating \JSON from Hashes
233
+ #
234
+ # When the source is a Ruby \Hash, JSON.generate returns
235
+ # a \String containing a \JSON object:
236
+ # ruby = {foo: 0, bar: 's', baz: :bat}
237
+ # json = JSON.generate(ruby)
238
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
239
+ #
240
+ # The Ruby \Hash array may contain nested arrays, hashes, and scalars
241
+ # to any depth:
242
+ # ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
243
+ # json = JSON.generate(ruby)
244
+ # json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}'
245
+ #
246
+ # ==== Generating \JSON from Other Objects
247
+ #
248
+ # When the source is neither an \Array nor a \Hash,
249
+ # the generated \JSON data depends on the class of the source.
250
+ #
251
+ # When the source is a Ruby \Integer or \Float, JSON.generate returns
252
+ # a \String containing a \JSON number:
253
+ # JSON.generate(42) # => '42'
254
+ # JSON.generate(0.42) # => '0.42'
255
+ #
256
+ # When the source is a Ruby \String, JSON.generate returns
257
+ # a \String containing a \JSON string (with double-quotes):
258
+ # JSON.generate('A string') # => '"A string"'
259
+ #
260
+ # When the source is +true+, +false+ or +nil+, JSON.generate returns
261
+ # a \String containing the corresponding \JSON token:
262
+ # JSON.generate(true) # => 'true'
263
+ # JSON.generate(false) # => 'false'
264
+ # JSON.generate(nil) # => 'null'
265
+ #
266
+ # When the source is none of the above, JSON.generate returns
267
+ # a \String containing a \JSON string representation of the source:
268
+ # JSON.generate(:foo) # => '"foo"'
269
+ # JSON.generate(Complex(0, 0)) # => '"0+0i"'
270
+ # JSON.generate(Dir.new('.')) # => '"#<Dir>"'
271
+ #
272
+ # ==== Generating Options
273
+ #
274
+ # ====== Input Options
275
+ #
276
+ # Option +allow_nan+ (boolean) specifies whether
277
+ # +NaN+, +Infinity+, and <tt>-Infinity</tt> may be generated;
278
+ # defaults to +false+.
279
+ #
280
+ # With the default, +false+:
281
+ # # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
282
+ # JSON.generate(JSON::NaN)
283
+ # # Raises JSON::GeneratorError (917: Infinity not allowed in JSON):
284
+ # JSON.generate(JSON::Infinity)
285
+ # # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON):
286
+ # JSON.generate(JSON::MinusInfinity)
287
+ #
288
+ # Allow:
289
+ # ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
290
+ # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
291
+ #
292
+ # ---
293
+ #
294
+ # Option +max_nesting+ (\Integer) specifies the maximum nesting depth
295
+ # in +obj+; defaults to +100+.
296
+ #
297
+ # With the default, +100+:
298
+ # obj = [[[[[[0]]]]]]
299
+ # JSON.generate(obj) # => '[[[[[[0]]]]]]'
300
+ #
301
+ # Too deep:
302
+ # # Raises JSON::NestingError (nesting of 2 is too deep):
303
+ # JSON.generate(obj, max_nesting: 2)
304
+ #
305
+ # ====== Output Options
306
+ #
307
+ # The default formatting options generate the most compact
308
+ # \JSON data, all on one line and with no whitespace.
309
+ #
310
+ # You can use these formatting options to generate
311
+ # \JSON data in a more open format, using whitespace.
312
+ # See also JSON.pretty_generate.
313
+ #
314
+ # - Option +array_nl+ (\String) specifies a string (usually a newline)
315
+ # to be inserted after each \JSON array; defaults to the empty \String, <tt>''</tt>.
316
+ # - Option +object_nl+ (\String) specifies a string (usually a newline)
317
+ # to be inserted after each \JSON object; defaults to the empty \String, <tt>''</tt>.
318
+ # - Option +indent+ (\String) specifies the string (usually spaces) to be
319
+ # used for indentation; defaults to the empty \String, <tt>''</tt>;
320
+ # defaults to the empty \String, <tt>''</tt>;
321
+ # has no effect unless options +array_nl+ or +object_nl+ specify newlines.
322
+ # - Option +space+ (\String) specifies a string (usually a space) to be
323
+ # inserted after the colon in each \JSON object's pair;
324
+ # defaults to the empty \String, <tt>''</tt>.
325
+ # - Option +space_before+ (\String) specifies a string (usually a space) to be
326
+ # inserted before the colon in each \JSON object's pair;
327
+ # defaults to the empty \String, <tt>''</tt>.
328
+ #
329
+ # In this example, +obj+ is used first to generate the shortest
330
+ # \JSON data (no whitespace), then again with all formatting options
331
+ # specified:
332
+ #
333
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
334
+ # json = JSON.generate(obj)
335
+ # puts 'Compact:', json
336
+ # opts = {
337
+ # array_nl: "\n",
338
+ # object_nl: "\n",
339
+ # indent: ' ',
340
+ # space_before: ' ',
341
+ # space: ' '
342
+ # }
343
+ # puts 'Open:', JSON.generate(obj, opts)
344
+ #
345
+ # Output:
346
+ # Compact:
347
+ # {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}}
348
+ # Open:
349
+ # {
350
+ # "foo" : [
351
+ # "bar",
352
+ # "baz"
353
+ # ],
354
+ # "bat" : {
355
+ # "bam" : 0,
356
+ # "bad" : 1
357
+ # }
358
+ # }
359
+ #
360
+ # == \JSON Additions
361
+ #
362
+ # When you "round trip" a non-\String object from Ruby to \JSON and back,
363
+ # you have a new \String, instead of the object you began with:
364
+ # ruby0 = Range.new(0, 2)
365
+ # json = JSON.generate(ruby0)
366
+ # json # => '0..2"'
367
+ # ruby1 = JSON.parse(json)
368
+ # ruby1 # => '0..2'
369
+ # ruby1.class # => String
370
+ #
371
+ # You can use \JSON _additions_ to preserve the original object.
372
+ # The addition is an extension of a ruby class, so that:
373
+ # - \JSON.generate stores more information in the \JSON string.
374
+ # - \JSON.parse, called with option +create_additions+,
375
+ # uses that information to create a proper Ruby object.
376
+ #
377
+ # This example shows a \Range being generated into \JSON
378
+ # and parsed back into Ruby, both without and with
379
+ # the addition for \Range:
380
+ # ruby = Range.new(0, 2)
381
+ # # This passage does not use the addition for Range.
382
+ # json0 = JSON.generate(ruby)
383
+ # ruby0 = JSON.parse(json0)
384
+ # # This passage uses the addition for Range.
385
+ # require 'json/add/range'
386
+ # json1 = JSON.generate(ruby)
387
+ # ruby1 = JSON.parse(json1, create_additions: true)
388
+ # # Make a nice display.
389
+ # display = <<EOT
390
+ # Generated JSON:
391
+ # Without addition: #{json0} (#{json0.class})
392
+ # With addition: #{json1} (#{json1.class})
393
+ # Parsed JSON:
394
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
395
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
396
+ # EOT
397
+ # puts display
398
+ #
399
+ # This output shows the different results:
400
+ # Generated JSON:
401
+ # Without addition: "0..2" (String)
402
+ # With addition: {"json_class":"Range","a":[0,2,false]} (String)
403
+ # Parsed JSON:
404
+ # Without addition: "0..2" (String)
405
+ # With addition: 0..2 (Range)
406
+ #
407
+ # The \JSON module includes additions for certain classes.
408
+ # You can also craft custom additions.
409
+ # See {Custom \JSON Additions}[#module-JSON-label-Custom+JSON+Additions].
410
+ #
411
+ # === Built-in Additions
412
+ #
413
+ # The \JSON module includes additions for certain classes.
414
+ # To use an addition, +require+ its source:
415
+ # - BigDecimal: <tt>require 'json/add/bigdecimal'</tt>
416
+ # - Complex: <tt>require 'json/add/complex'</tt>
417
+ # - Date: <tt>require 'json/add/date'</tt>
418
+ # - DateTime: <tt>require 'json/add/date_time'</tt>
419
+ # - Exception: <tt>require 'json/add/exception'</tt>
420
+ # - OpenStruct: <tt>require 'json/add/ostruct'</tt>
421
+ # - Range: <tt>require 'json/add/range'</tt>
422
+ # - Rational: <tt>require 'json/add/rational'</tt>
423
+ # - Regexp: <tt>require 'json/add/regexp'</tt>
424
+ # - Set: <tt>require 'json/add/set'</tt>
425
+ # - Struct: <tt>require 'json/add/struct'</tt>
426
+ # - Symbol: <tt>require 'json/add/symbol'</tt>
427
+ # - Time: <tt>require 'json/add/time'</tt>
428
+ #
429
+ # To reduce punctuation clutter, the examples below
430
+ # show the generated \JSON via +puts+, rather than the usual +inspect+,
431
+ #
432
+ # \BigDecimal:
433
+ # require 'json/add/bigdecimal'
434
+ # ruby0 = BigDecimal(0) # 0.0
435
+ # json = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"}
436
+ # ruby1 = JSON.parse(json, create_additions: true) # 0.0
437
+ # ruby1.class # => BigDecimal
438
+ #
439
+ # \Complex:
440
+ # require 'json/add/complex'
441
+ # ruby0 = Complex(1+0i) # 1+0i
442
+ # json = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0}
443
+ # ruby1 = JSON.parse(json, create_additions: true) # 1+0i
444
+ # ruby1.class # Complex
445
+ #
446
+ # \Date:
447
+ # require 'json/add/date'
448
+ # ruby0 = Date.today # 2020-05-02
449
+ # json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0}
450
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02
451
+ # ruby1.class # Date
452
+ #
453
+ # \DateTime:
454
+ # require 'json/add/date_time'
455
+ # ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00
456
+ # json = JSON.generate(ruby0) # {"json_class":"DateTime","y":2020,"m":5,"d":2,"H":10,"M":38,"S":13,"of":"-5/24","sg":2299161.0}
457
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00
458
+ # ruby1.class # DateTime
459
+ #
460
+ # \Exception (and its subclasses including \RuntimeError):
461
+ # require 'json/add/exception'
462
+ # ruby0 = Exception.new('A message') # A message
463
+ # json = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null}
464
+ # ruby1 = JSON.parse(json, create_additions: true) # A message
465
+ # ruby1.class # Exception
466
+ # ruby0 = RuntimeError.new('Another message') # Another message
467
+ # json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null}
468
+ # ruby1 = JSON.parse(json, create_additions: true) # Another message
469
+ # ruby1.class # RuntimeError
470
+ #
471
+ # \OpenStruct:
472
+ # require 'json/add/ostruct'
473
+ # ruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # #<OpenStruct name="Matz", language="Ruby">
474
+ # json = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}}
475
+ # ruby1 = JSON.parse(json, create_additions: true) # #<OpenStruct name="Matz", language="Ruby">
476
+ # ruby1.class # OpenStruct
477
+ #
478
+ # \Range:
479
+ # require 'json/add/range'
480
+ # ruby0 = Range.new(0, 2) # 0..2
481
+ # json = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]}
482
+ # ruby1 = JSON.parse(json, create_additions: true) # 0..2
483
+ # ruby1.class # Range
484
+ #
485
+ # \Rational:
486
+ # require 'json/add/rational'
487
+ # ruby0 = Rational(1, 3) # 1/3
488
+ # json = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3}
489
+ # ruby1 = JSON.parse(json, create_additions: true) # 1/3
490
+ # ruby1.class # Rational
491
+ #
492
+ # \Regexp:
493
+ # require 'json/add/regexp'
494
+ # ruby0 = Regexp.new('foo') # (?-mix:foo)
495
+ # json = JSON.generate(ruby0) # {"json_class":"Regexp","o":0,"s":"foo"}
496
+ # ruby1 = JSON.parse(json, create_additions: true) # (?-mix:foo)
497
+ # ruby1.class # Regexp
498
+ #
499
+ # \Set:
500
+ # require 'json/add/set'
501
+ # ruby0 = Set.new([0, 1, 2]) # #<Set: {0, 1, 2}>
502
+ # json = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]}
503
+ # ruby1 = JSON.parse(json, create_additions: true) # #<Set: {0, 1, 2}>
504
+ # ruby1.class # Set
505
+ #
506
+ # \Struct:
507
+ # require 'json/add/struct'
508
+ # Customer = Struct.new(:name, :address) # Customer
509
+ # ruby0 = Customer.new("Dave", "123 Main") # #<struct Customer name="Dave", address="123 Main">
510
+ # json = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]}
511
+ # ruby1 = JSON.parse(json, create_additions: true) # #<struct Customer name="Dave", address="123 Main">
512
+ # ruby1.class # Customer
513
+ #
514
+ # \Symbol:
515
+ # require 'json/add/symbol'
516
+ # ruby0 = :foo # foo
517
+ # json = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"}
518
+ # ruby1 = JSON.parse(json, create_additions: true) # foo
519
+ # ruby1.class # Symbol
520
+ #
521
+ # \Time:
522
+ # require 'json/add/time'
523
+ # ruby0 = Time.now # 2020-05-02 11:28:26 -0500
524
+ # json = JSON.generate(ruby0) # {"json_class":"Time","s":1588436906,"n":840560000}
525
+ # ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 11:28:26 -0500
526
+ # ruby1.class # Time
527
+ #
528
+ #
529
+ # === Custom \JSON Additions
530
+ #
531
+ # In addition to the \JSON additions provided,
532
+ # you can craft \JSON additions of your own,
533
+ # either for Ruby built-in classes or for user-defined classes.
534
+ #
535
+ # Here's a user-defined class +Foo+:
536
+ # class Foo
537
+ # attr_accessor :bar, :baz
538
+ # def initialize(bar, baz)
539
+ # self.bar = bar
540
+ # self.baz = baz
541
+ # end
542
+ # end
543
+ #
544
+ # Here's the \JSON addition for it:
545
+ # # Extend class Foo with JSON addition.
546
+ # class Foo
547
+ # # Serialize Foo object with its class name and arguments
548
+ # def to_json(*args)
549
+ # {
550
+ # JSON.create_id => self.class.name,
551
+ # 'a' => [ bar, baz ]
552
+ # }.to_json(*args)
553
+ # end
554
+ # # Deserialize JSON string by constructing new Foo object with arguments.
555
+ # def self.json_create(object)
556
+ # new(*object['a'])
557
+ # end
558
+ # end
559
+ #
560
+ # Demonstration:
561
+ # require 'json'
562
+ # # This Foo object has no custom addition.
563
+ # foo0 = Foo.new(0, 1)
564
+ # json0 = JSON.generate(foo0)
565
+ # obj0 = JSON.parse(json0)
566
+ # # Lood the custom addition.
567
+ # require_relative 'foo_addition'
568
+ # # This foo has the custom addition.
569
+ # foo1 = Foo.new(0, 1)
570
+ # json1 = JSON.generate(foo1)
571
+ # obj1 = JSON.parse(json1, create_additions: true)
572
+ # # Make a nice display.
573
+ # display = <<EOT
574
+ # Generated JSON:
575
+ # Without custom addition: #{json0} (#{json0.class})
576
+ # With custom addition: #{json1} (#{json1.class})
577
+ # Parsed JSON:
578
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
579
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
580
+ # EOT
581
+ # puts display
582
+ #
583
+ # Output:
584
+ #
585
+ # Generated JSON:
586
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
587
+ # With custom addition: {"json_class":"Foo","a":[0,1]} (String)
588
+ # Parsed JSON:
589
+ # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
590
+ # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
591
+ #
592
+ # source://json//lib/json/version.rb#2
593
+ module JSON
594
+ private
595
+
596
+ # :call-seq:
597
+ # JSON.dump(obj, io = nil, limit = nil)
598
+ #
599
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
600
+ #
601
+ # The default options can be changed via method JSON.dump_default_options.
602
+ #
603
+ # - Argument +io+, if given, should respond to method +write+;
604
+ # the \JSON \String is written to +io+, and +io+ is returned.
605
+ # If +io+ is not given, the \JSON \String is returned.
606
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
607
+ #
608
+ # ---
609
+ #
610
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
611
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
612
+ # json = JSON.dump(obj)
613
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
614
+ #
615
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
616
+ # path = 't.json'
617
+ # File.open(path, 'w') do |file|
618
+ # JSON.dump(obj, file)
619
+ # end # => #<File:t.json (closed)>
620
+ # puts File.read(path)
621
+ # Output:
622
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
623
+ #
624
+ # source://json//lib/json/common.rb#631
625
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil)); end
626
+
627
+ # :call-seq:
628
+ # JSON.fast_generate(obj, opts) -> new_string
629
+ #
630
+ # Arguments +obj+ and +opts+ here are the same as
631
+ # arguments +obj+ and +opts+ in JSON.generate.
632
+ #
633
+ # By default, generates \JSON data without checking
634
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
635
+ #
636
+ # Raises an exception if +obj+ contains circular references:
637
+ # a = []; b = []; a.push(b); b.push(a)
638
+ # # Raises SystemStackError (stack level too deep):
639
+ # JSON.fast_generate(a)
640
+ #
641
+ # source://json//lib/json/common.rb#335
642
+ def fast_generate(obj, opts = T.unsafe(nil)); end
643
+
644
+ # :stopdoc:
645
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
646
+ #
647
+ # source://json//lib/json/common.rb#335
648
+ def fast_unparse(obj, opts = T.unsafe(nil)); end
649
+
650
+ # :call-seq:
651
+ # JSON.generate(obj, opts = nil) -> new_string
652
+ #
653
+ # Returns a \String containing the generated \JSON data.
654
+ #
655
+ # See also JSON.fast_generate, JSON.pretty_generate.
656
+ #
657
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
658
+ #
659
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
660
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
661
+ #
662
+ # ---
663
+ #
664
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
665
+ # obj = ["foo", 1.0, true, false, nil]
666
+ # json = JSON.generate(obj)
667
+ # json # => '["foo",1.0,true,false,null]'
668
+ #
669
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
670
+ # obj = {foo: 0, bar: 's', baz: :bat}
671
+ # json = JSON.generate(obj)
672
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
673
+ #
674
+ # For examples of generating from other Ruby objects, see
675
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
676
+ #
677
+ # ---
678
+ #
679
+ # Raises an exception if any formatting option is not a \String.
680
+ #
681
+ # Raises an exception if +obj+ contains circular references:
682
+ # a = []; b = []; a.push(b); b.push(a)
683
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
684
+ # JSON.generate(a)
685
+ #
686
+ # source://json//lib/json/common.rb#296
687
+ def generate(obj, opts = T.unsafe(nil)); end
688
+
689
+ # :call-seq:
690
+ # JSON.load(source, proc = nil, options = {}) -> object
691
+ #
692
+ # Returns the Ruby objects created by parsing the given +source+.
693
+ #
694
+ # - Argument +source+ must be, or be convertible to, a \String:
695
+ # - If +source+ responds to instance method +to_str+,
696
+ # <tt>source.to_str</tt> becomes the source.
697
+ # - If +source+ responds to instance method +to_io+,
698
+ # <tt>source.to_io.read</tt> becomes the source.
699
+ # - If +source+ responds to instance method +read+,
700
+ # <tt>source.read</tt> becomes the source.
701
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
702
+ # - Option +allow_blank+ specifies a truthy value.
703
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
704
+ # - Otherwise, +source+ remains the source.
705
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
706
+ # It will be called recursively with each result (depth-first order).
707
+ # See details below.
708
+ # BEWARE: This method is meant to serialise data from trusted user input,
709
+ # like from your own database server or clients under your control, it could
710
+ # be dangerous to allow untrusted users to pass JSON sources into it.
711
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
712
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
713
+ # The default options can be changed via method JSON.load_default_options=.
714
+ #
715
+ # ---
716
+ #
717
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
718
+ # <tt>parse(source, opts)</tt>; see #parse.
719
+ #
720
+ # Source for following examples:
721
+ # source = <<-EOT
722
+ # {
723
+ # "name": "Dave",
724
+ # "age" :40,
725
+ # "hats": [
726
+ # "Cattleman's",
727
+ # "Panama",
728
+ # "Tophat"
729
+ # ]
730
+ # }
731
+ # EOT
732
+ #
733
+ # Load a \String:
734
+ # ruby = JSON.load(source)
735
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
736
+ #
737
+ # Load an \IO object:
738
+ # require 'stringio'
739
+ # object = JSON.load(StringIO.new(source))
740
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
741
+ #
742
+ # Load a \File object:
743
+ # path = 't.json'
744
+ # File.write(path, source)
745
+ # File.open(path) do |file|
746
+ # JSON.load(file)
747
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
748
+ #
749
+ # ---
750
+ #
751
+ # When +proc+ is given:
752
+ # - Modifies +source+ as above.
753
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
754
+ # - Recursively calls <tt>proc(result)</tt>.
755
+ # - Returns the final result.
756
+ #
757
+ # Example:
758
+ # require 'json'
759
+ #
760
+ # # Some classes for the example.
761
+ # class Base
762
+ # def initialize(attributes)
763
+ # @attributes = attributes
764
+ # end
765
+ # end
766
+ # class User < Base; end
767
+ # class Account < Base; end
768
+ # class Admin < Base; end
769
+ # # The JSON source.
770
+ # json = <<-EOF
771
+ # {
772
+ # "users": [
773
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
774
+ # {"type": "User", "username": "john", "email": "john@example.com"}
775
+ # ],
776
+ # "accounts": [
777
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
778
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
779
+ # ],
780
+ # "admins": {"type": "Admin", "password": "0wn3d"}
781
+ # }
782
+ # EOF
783
+ # # Deserializer method.
784
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
785
+ # type = obj.is_a?(Hash) && obj["type"]
786
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
787
+ # end
788
+ # # Call to JSON.load
789
+ # ruby = JSON.load(json, proc {|obj|
790
+ # case obj
791
+ # when Hash
792
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
793
+ # when Array
794
+ # obj.map! {|v| deserialize_obj v }
795
+ # end
796
+ # })
797
+ # pp ruby
798
+ # Output:
799
+ # {"users"=>
800
+ # [#<User:0x00000000064c4c98
801
+ # @attributes=
802
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
803
+ # #<User:0x00000000064c4bd0
804
+ # @attributes=
805
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
806
+ # "accounts"=>
807
+ # [{"account"=>
808
+ # #<Account:0x00000000064c4928
809
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
810
+ # {"account"=>
811
+ # #<Account:0x00000000064c4680
812
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
813
+ # "admins"=>
814
+ # #<Admin:0x00000000064c41f8
815
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
816
+ #
817
+ # source://json//lib/json/common.rb#557
818
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
819
+
820
+ # :call-seq:
821
+ # JSON.load_file(path, opts={}) -> object
822
+ #
823
+ # Calls:
824
+ # parse(File.read(path), opts)
825
+ #
826
+ # See method #parse.
827
+ #
828
+ # source://json//lib/json/common.rb#245
829
+ def load_file(filespec, opts = T.unsafe(nil)); end
830
+
831
+ # :call-seq:
832
+ # JSON.load_file!(path, opts = {})
833
+ #
834
+ # Calls:
835
+ # JSON.parse!(File.read(path, opts))
836
+ #
837
+ # See method #parse!
838
+ #
839
+ # source://json//lib/json/common.rb#256
840
+ def load_file!(filespec, opts = T.unsafe(nil)); end
841
+
842
+ # :call-seq:
843
+ # JSON.parse(source, opts) -> object
844
+ #
845
+ # Returns the Ruby objects created by parsing the given +source+.
846
+ #
847
+ # Argument +source+ contains the \String to be parsed.
848
+ #
849
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
850
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
851
+ #
852
+ # ---
853
+ #
854
+ # When +source+ is a \JSON array, returns a Ruby \Array:
855
+ # source = '["foo", 1.0, true, false, null]'
856
+ # ruby = JSON.parse(source)
857
+ # ruby # => ["foo", 1.0, true, false, nil]
858
+ # ruby.class # => Array
859
+ #
860
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
861
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
862
+ # ruby = JSON.parse(source)
863
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
864
+ # ruby.class # => Hash
865
+ #
866
+ # For examples of parsing for all \JSON data types, see
867
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
868
+ #
869
+ # Parses nested JSON objects:
870
+ # source = <<-EOT
871
+ # {
872
+ # "name": "Dave",
873
+ # "age" :40,
874
+ # "hats": [
875
+ # "Cattleman's",
876
+ # "Panama",
877
+ # "Tophat"
878
+ # ]
879
+ # }
880
+ # EOT
881
+ # ruby = JSON.parse(source)
882
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
883
+ #
884
+ # ---
885
+ #
886
+ # Raises an exception if +source+ is not valid JSON:
887
+ # # Raises JSON::ParserError (783: unexpected token at ''):
888
+ # JSON.parse('')
889
+ #
890
+ # source://json//lib/json/common.rb#215
891
+ def parse(source, opts = T.unsafe(nil)); end
892
+
893
+ # :call-seq:
894
+ # JSON.parse!(source, opts) -> object
895
+ #
896
+ # Calls
897
+ # parse(source, opts)
898
+ # with +source+ and possibly modified +opts+.
899
+ #
900
+ # Differences from JSON.parse:
901
+ # - Option +max_nesting+, if not provided, defaults to +false+,
902
+ # which disables checking for nesting depth.
903
+ # - Option +allow_nan+, if not provided, defaults to +true+.
904
+ #
905
+ # source://json//lib/json/common.rb#230
906
+ def parse!(source, opts = T.unsafe(nil)); end
907
+
908
+ # :call-seq:
909
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
910
+ #
911
+ # Arguments +obj+ and +opts+ here are the same as
912
+ # arguments +obj+ and +opts+ in JSON.generate.
913
+ #
914
+ # Default options are:
915
+ # {
916
+ # indent: ' ', # Two spaces
917
+ # space: ' ', # One space
918
+ # array_nl: "\n", # Newline
919
+ # object_nl: "\n" # Newline
920
+ # }
921
+ #
922
+ # Example:
923
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
924
+ # json = JSON.pretty_generate(obj)
925
+ # puts json
926
+ # Output:
927
+ # {
928
+ # "foo": [
929
+ # "bar",
930
+ # "baz"
931
+ # ],
932
+ # "bat": {
933
+ # "bam": 0,
934
+ # "bad": 1
935
+ # }
936
+ # }
937
+ #
938
+ # source://json//lib/json/common.rb#390
939
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
940
+
941
+ # :stopdoc:
942
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
943
+ #
944
+ # source://json//lib/json/common.rb#390
945
+ def pretty_unparse(obj, opts = T.unsafe(nil)); end
946
+
947
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
948
+ #
949
+ # source://json//lib/json/common.rb#575
950
+ def recurse_proc(result, &proc); end
951
+
952
+ # source://json//lib/json/common.rb#557
953
+ def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
954
+
955
+ # :stopdoc:
956
+ # I want to deprecate these later, so I'll first be silent about them, and
957
+ # later delete them.
958
+ #
959
+ # source://json//lib/json/common.rb#296
960
+ def unparse(obj, opts = T.unsafe(nil)); end
961
+
962
+ class << self
963
+ # :call-seq:
964
+ # JSON[object] -> new_array or new_string
965
+ #
966
+ # If +object+ is a \String,
967
+ # calls JSON.parse with +object+ and +opts+ (see method #parse):
968
+ # json = '[0, 1, null]'
969
+ # JSON[json]# => [0, 1, nil]
970
+ #
971
+ # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
972
+ # ruby = [0, 1, nil]
973
+ # JSON[ruby] # => '[0,1,null]'
974
+ #
975
+ # source://json//lib/json/common.rb#18
976
+ def [](object, opts = T.unsafe(nil)); end
977
+
978
+ # source://json//lib/json/common.rb#81
979
+ def create_fast_state; end
980
+
981
+ # Returns the current create identifier.
982
+ # See also JSON.create_id=.
983
+ #
984
+ # source://json//lib/json/common.rb#126
985
+ def create_id; end
986
+
987
+ # Sets create identifier, which is used to decide if the _json_create_
988
+ # hook of a class should be called; initial value is +json_class+:
989
+ # JSON.create_id # => 'json_class'
990
+ #
991
+ # source://json//lib/json/common.rb#120
992
+ def create_id=(new_value); end
993
+
994
+ # source://json//lib/json/common.rb#91
995
+ def create_pretty_state; end
996
+
997
+ # Return the constant located at _path_. The format of _path_ has to be
998
+ # either ::A::B::C or A::B::C. In any case, A has to be located at the top
999
+ # level (absolute namespace path?). If there doesn't exist a constant at
1000
+ # the given path, an ArgumentError is raised.
1001
+ #
1002
+ # source://json//lib/json/common.rb#42
1003
+ def deep_const_get(path); end
1004
+
1005
+ # :call-seq:
1006
+ # JSON.dump(obj, io = nil, limit = nil)
1007
+ #
1008
+ # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
1009
+ #
1010
+ # The default options can be changed via method JSON.dump_default_options.
1011
+ #
1012
+ # - Argument +io+, if given, should respond to method +write+;
1013
+ # the \JSON \String is written to +io+, and +io+ is returned.
1014
+ # If +io+ is not given, the \JSON \String is returned.
1015
+ # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
1016
+ #
1017
+ # ---
1018
+ #
1019
+ # When argument +io+ is not given, returns the \JSON \String generated from +obj+:
1020
+ # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
1021
+ # json = JSON.dump(obj)
1022
+ # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
1023
+ #
1024
+ # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
1025
+ # path = 't.json'
1026
+ # File.open(path, 'w') do |file|
1027
+ # JSON.dump(obj, file)
1028
+ # end # => #<File:t.json (closed)>
1029
+ # puts File.read(path)
1030
+ # Output:
1031
+ # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1032
+ #
1033
+ # source://json//lib/json/common.rb#631
1034
+ def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil)); end
1035
+
1036
+ # Sets or returns the default options for the JSON.dump method.
1037
+ # Initially:
1038
+ # opts = JSON.dump_default_options
1039
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
1040
+ #
1041
+ # source://json//lib/json/common.rb#596
1042
+ def dump_default_options; end
1043
+
1044
+ # Sets or returns the default options for the JSON.dump method.
1045
+ # Initially:
1046
+ # opts = JSON.dump_default_options
1047
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
1048
+ #
1049
+ # source://json//lib/json/common.rb#596
1050
+ def dump_default_options=(_arg0); end
1051
+
1052
+ # :call-seq:
1053
+ # JSON.fast_generate(obj, opts) -> new_string
1054
+ #
1055
+ # Arguments +obj+ and +opts+ here are the same as
1056
+ # arguments +obj+ and +opts+ in JSON.generate.
1057
+ #
1058
+ # By default, generates \JSON data without checking
1059
+ # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
1060
+ #
1061
+ # Raises an exception if +obj+ contains circular references:
1062
+ # a = []; b = []; a.push(b); b.push(a)
1063
+ # # Raises SystemStackError (stack level too deep):
1064
+ # JSON.fast_generate(a)
1065
+ #
1066
+ # source://json//lib/json/common.rb#335
1067
+ def fast_generate(obj, opts = T.unsafe(nil)); end
1068
+
1069
+ # :stopdoc:
1070
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1071
+ #
1072
+ # source://json//lib/json/common.rb#335
1073
+ def fast_unparse(obj, opts = T.unsafe(nil)); end
1074
+
1075
+ # :call-seq:
1076
+ # JSON.generate(obj, opts = nil) -> new_string
1077
+ #
1078
+ # Returns a \String containing the generated \JSON data.
1079
+ #
1080
+ # See also JSON.fast_generate, JSON.pretty_generate.
1081
+ #
1082
+ # Argument +obj+ is the Ruby object to be converted to \JSON.
1083
+ #
1084
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
1085
+ # See {Generating Options}[#module-JSON-label-Generating+Options].
1086
+ #
1087
+ # ---
1088
+ #
1089
+ # When +obj+ is an \Array, returns a \String containing a \JSON array:
1090
+ # obj = ["foo", 1.0, true, false, nil]
1091
+ # json = JSON.generate(obj)
1092
+ # json # => '["foo",1.0,true,false,null]'
1093
+ #
1094
+ # When +obj+ is a \Hash, returns a \String containing a \JSON object:
1095
+ # obj = {foo: 0, bar: 's', baz: :bat}
1096
+ # json = JSON.generate(obj)
1097
+ # json # => '{"foo":0,"bar":"s","baz":"bat"}'
1098
+ #
1099
+ # For examples of generating from other Ruby objects, see
1100
+ # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
1101
+ #
1102
+ # ---
1103
+ #
1104
+ # Raises an exception if any formatting option is not a \String.
1105
+ #
1106
+ # Raises an exception if +obj+ contains circular references:
1107
+ # a = []; b = []; a.push(b); b.push(a)
1108
+ # # Raises JSON::NestingError (nesting of 100 is too deep):
1109
+ # JSON.generate(a)
1110
+ #
1111
+ # source://json//lib/json/common.rb#296
1112
+ def generate(obj, opts = T.unsafe(nil)); end
1113
+
1114
+ # Returns the JSON generator module that is used by JSON. This is
1115
+ # either JSON::Ext::Generator or JSON::Pure::Generator:
1116
+ # JSON.generator # => JSON::Ext::Generator
1117
+ #
1118
+ # source://json//lib/json/common.rb#103
1119
+ def generator; end
1120
+
1121
+ # Set the module _generator_ to be used by JSON.
1122
+ #
1123
+ # source://json//lib/json/common.rb#58
1124
+ def generator=(generator); end
1125
+
1126
+ # Encodes string using String.encode.
1127
+ #
1128
+ # source://json//lib/json/common.rb#653
1129
+ def iconv(to, from, string); end
1130
+
1131
+ # :call-seq:
1132
+ # JSON.load(source, proc = nil, options = {}) -> object
1133
+ #
1134
+ # Returns the Ruby objects created by parsing the given +source+.
1135
+ #
1136
+ # - Argument +source+ must be, or be convertible to, a \String:
1137
+ # - If +source+ responds to instance method +to_str+,
1138
+ # <tt>source.to_str</tt> becomes the source.
1139
+ # - If +source+ responds to instance method +to_io+,
1140
+ # <tt>source.to_io.read</tt> becomes the source.
1141
+ # - If +source+ responds to instance method +read+,
1142
+ # <tt>source.read</tt> becomes the source.
1143
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1144
+ # - Option +allow_blank+ specifies a truthy value.
1145
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1146
+ # - Otherwise, +source+ remains the source.
1147
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1148
+ # It will be called recursively with each result (depth-first order).
1149
+ # See details below.
1150
+ # BEWARE: This method is meant to serialise data from trusted user input,
1151
+ # like from your own database server or clients under your control, it could
1152
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1153
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1154
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1155
+ # The default options can be changed via method JSON.load_default_options=.
1156
+ #
1157
+ # ---
1158
+ #
1159
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1160
+ # <tt>parse(source, opts)</tt>; see #parse.
1161
+ #
1162
+ # Source for following examples:
1163
+ # source = <<-EOT
1164
+ # {
1165
+ # "name": "Dave",
1166
+ # "age" :40,
1167
+ # "hats": [
1168
+ # "Cattleman's",
1169
+ # "Panama",
1170
+ # "Tophat"
1171
+ # ]
1172
+ # }
1173
+ # EOT
1174
+ #
1175
+ # Load a \String:
1176
+ # ruby = JSON.load(source)
1177
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1178
+ #
1179
+ # Load an \IO object:
1180
+ # require 'stringio'
1181
+ # object = JSON.load(StringIO.new(source))
1182
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1183
+ #
1184
+ # Load a \File object:
1185
+ # path = 't.json'
1186
+ # File.write(path, source)
1187
+ # File.open(path) do |file|
1188
+ # JSON.load(file)
1189
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1190
+ #
1191
+ # ---
1192
+ #
1193
+ # When +proc+ is given:
1194
+ # - Modifies +source+ as above.
1195
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1196
+ # - Recursively calls <tt>proc(result)</tt>.
1197
+ # - Returns the final result.
1198
+ #
1199
+ # Example:
1200
+ # require 'json'
1201
+ #
1202
+ # # Some classes for the example.
1203
+ # class Base
1204
+ # def initialize(attributes)
1205
+ # @attributes = attributes
1206
+ # end
1207
+ # end
1208
+ # class User < Base; end
1209
+ # class Account < Base; end
1210
+ # class Admin < Base; end
1211
+ # # The JSON source.
1212
+ # json = <<-EOF
1213
+ # {
1214
+ # "users": [
1215
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1216
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1217
+ # ],
1218
+ # "accounts": [
1219
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1220
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1221
+ # ],
1222
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1223
+ # }
1224
+ # EOF
1225
+ # # Deserializer method.
1226
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1227
+ # type = obj.is_a?(Hash) && obj["type"]
1228
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1229
+ # end
1230
+ # # Call to JSON.load
1231
+ # ruby = JSON.load(json, proc {|obj|
1232
+ # case obj
1233
+ # when Hash
1234
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1235
+ # when Array
1236
+ # obj.map! {|v| deserialize_obj v }
1237
+ # end
1238
+ # })
1239
+ # pp ruby
1240
+ # Output:
1241
+ # {"users"=>
1242
+ # [#<User:0x00000000064c4c98
1243
+ # @attributes=
1244
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1245
+ # #<User:0x00000000064c4bd0
1246
+ # @attributes=
1247
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1248
+ # "accounts"=>
1249
+ # [{"account"=>
1250
+ # #<Account:0x00000000064c4928
1251
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1252
+ # {"account"=>
1253
+ # #<Account:0x00000000064c4680
1254
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1255
+ # "admins"=>
1256
+ # #<Admin:0x00000000064c41f8
1257
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1258
+ #
1259
+ # source://json//lib/json/common.rb#557
1260
+ def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1261
+
1262
+ # Sets or returns default options for the JSON.load method.
1263
+ # Initially:
1264
+ # opts = JSON.load_default_options
1265
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1266
+ #
1267
+ # source://json//lib/json/common.rb#420
1268
+ def load_default_options; end
1269
+
1270
+ # Sets or returns default options for the JSON.load method.
1271
+ # Initially:
1272
+ # opts = JSON.load_default_options
1273
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1274
+ #
1275
+ # source://json//lib/json/common.rb#420
1276
+ def load_default_options=(_arg0); end
1277
+
1278
+ # :call-seq:
1279
+ # JSON.load_file(path, opts={}) -> object
1280
+ #
1281
+ # Calls:
1282
+ # parse(File.read(path), opts)
1283
+ #
1284
+ # See method #parse.
1285
+ #
1286
+ # source://json//lib/json/common.rb#245
1287
+ def load_file(filespec, opts = T.unsafe(nil)); end
1288
+
1289
+ # :call-seq:
1290
+ # JSON.load_file!(path, opts = {})
1291
+ #
1292
+ # Calls:
1293
+ # JSON.parse!(File.read(path, opts))
1294
+ #
1295
+ # See method #parse!
1296
+ #
1297
+ # source://json//lib/json/common.rb#256
1298
+ def load_file!(filespec, opts = T.unsafe(nil)); end
1299
+
1300
+ # :call-seq:
1301
+ # JSON.parse(source, opts) -> object
1302
+ #
1303
+ # Returns the Ruby objects created by parsing the given +source+.
1304
+ #
1305
+ # Argument +source+ contains the \String to be parsed.
1306
+ #
1307
+ # Argument +opts+, if given, contains a \Hash of options for the parsing.
1308
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1309
+ #
1310
+ # ---
1311
+ #
1312
+ # When +source+ is a \JSON array, returns a Ruby \Array:
1313
+ # source = '["foo", 1.0, true, false, null]'
1314
+ # ruby = JSON.parse(source)
1315
+ # ruby # => ["foo", 1.0, true, false, nil]
1316
+ # ruby.class # => Array
1317
+ #
1318
+ # When +source+ is a \JSON object, returns a Ruby \Hash:
1319
+ # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
1320
+ # ruby = JSON.parse(source)
1321
+ # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
1322
+ # ruby.class # => Hash
1323
+ #
1324
+ # For examples of parsing for all \JSON data types, see
1325
+ # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1326
+ #
1327
+ # Parses nested JSON objects:
1328
+ # source = <<-EOT
1329
+ # {
1330
+ # "name": "Dave",
1331
+ # "age" :40,
1332
+ # "hats": [
1333
+ # "Cattleman's",
1334
+ # "Panama",
1335
+ # "Tophat"
1336
+ # ]
1337
+ # }
1338
+ # EOT
1339
+ # ruby = JSON.parse(source)
1340
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1341
+ #
1342
+ # ---
1343
+ #
1344
+ # Raises an exception if +source+ is not valid JSON:
1345
+ # # Raises JSON::ParserError (783: unexpected token at ''):
1346
+ # JSON.parse('')
1347
+ #
1348
+ # source://json//lib/json/common.rb#215
1349
+ def parse(source, opts = T.unsafe(nil)); end
1350
+
1351
+ # :call-seq:
1352
+ # JSON.parse!(source, opts) -> object
1353
+ #
1354
+ # Calls
1355
+ # parse(source, opts)
1356
+ # with +source+ and possibly modified +opts+.
1357
+ #
1358
+ # Differences from JSON.parse:
1359
+ # - Option +max_nesting+, if not provided, defaults to +false+,
1360
+ # which disables checking for nesting depth.
1361
+ # - Option +allow_nan+, if not provided, defaults to +true+.
1362
+ #
1363
+ # source://json//lib/json/common.rb#230
1364
+ def parse!(source, opts = T.unsafe(nil)); end
1365
+
1366
+ # Returns the JSON parser class that is used by JSON. This is either
1367
+ # JSON::Ext::Parser or JSON::Pure::Parser:
1368
+ # JSON.parser # => JSON::Ext::Parser
1369
+ #
1370
+ # source://json//lib/json/common.rb#29
1371
+ def parser; end
1372
+
1373
+ # Set the JSON parser class _parser_ to be used by JSON.
1374
+ #
1375
+ # source://json//lib/json/common.rb#32
1376
+ def parser=(parser); end
1377
+
1378
+ # :call-seq:
1379
+ # JSON.pretty_generate(obj, opts = nil) -> new_string
1380
+ #
1381
+ # Arguments +obj+ and +opts+ here are the same as
1382
+ # arguments +obj+ and +opts+ in JSON.generate.
1383
+ #
1384
+ # Default options are:
1385
+ # {
1386
+ # indent: ' ', # Two spaces
1387
+ # space: ' ', # One space
1388
+ # array_nl: "\n", # Newline
1389
+ # object_nl: "\n" # Newline
1390
+ # }
1391
+ #
1392
+ # Example:
1393
+ # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
1394
+ # json = JSON.pretty_generate(obj)
1395
+ # puts json
1396
+ # Output:
1397
+ # {
1398
+ # "foo": [
1399
+ # "bar",
1400
+ # "baz"
1401
+ # ],
1402
+ # "bat": {
1403
+ # "bam": 0,
1404
+ # "bad": 1
1405
+ # }
1406
+ # }
1407
+ #
1408
+ # source://json//lib/json/common.rb#390
1409
+ def pretty_generate(obj, opts = T.unsafe(nil)); end
1410
+
1411
+ # :stopdoc:
1412
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1413
+ #
1414
+ # source://json//lib/json/common.rb#390
1415
+ def pretty_unparse(obj, opts = T.unsafe(nil)); end
1416
+
1417
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1418
+ #
1419
+ # source://json//lib/json/common.rb#575
1420
+ def recurse_proc(result, &proc); end
1421
+
1422
+ # source://json//lib/json/common.rb#557
1423
+ def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1424
+
1425
+ # Sets or Returns the JSON generator state class that is used by JSON. This is
1426
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1427
+ # JSON.state # => JSON::Ext::Generator::State
1428
+ #
1429
+ # source://json//lib/json/common.rb#108
1430
+ def state; end
1431
+
1432
+ # Sets or Returns the JSON generator state class that is used by JSON. This is
1433
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1434
+ # JSON.state # => JSON::Ext::Generator::State
1435
+ #
1436
+ # source://json//lib/json/common.rb#108
1437
+ def state=(_arg0); end
1438
+
1439
+ # :stopdoc:
1440
+ # I want to deprecate these later, so I'll first be silent about them, and
1441
+ # later delete them.
1442
+ #
1443
+ # source://json//lib/json/common.rb#296
1444
+ def unparse(obj, opts = T.unsafe(nil)); end
1445
+ end
1446
+ end
1447
+
1448
+ # source://json//lib/json/common.rb#114
1449
+ JSON::CREATE_ID_TLS_KEY = T.let(T.unsafe(nil), String)
1450
+
1451
+ # source://json//lib/json/common.rb#111
1452
+ JSON::DEFAULT_CREATE_ID = T.let(T.unsafe(nil), String)
1453
+
1454
+ # source://json//lib/json/generic_object.rb#5
1455
+ class JSON::GenericObject < ::OpenStruct
1456
+ # source://json//lib/json/generic_object.rb#63
1457
+ def as_json(*_arg0); end
1458
+
1459
+ # source://json//lib/json/generic_object.rb#47
1460
+ def to_hash; end
1461
+
1462
+ # source://json//lib/json/generic_object.rb#67
1463
+ def to_json(*a); end
1464
+
1465
+ # source://json//lib/json/generic_object.rb#59
1466
+ def |(other); end
1467
+
1468
+ class << self
1469
+ # source://json//lib/json/generic_object.rb#41
1470
+ def dump(obj, *args); end
1471
+
1472
+ # source://json//lib/json/generic_object.rb#21
1473
+ def from_hash(object); end
1474
+
1475
+ # Sets the attribute json_creatable
1476
+ #
1477
+ # @param value the value to set the attribute json_creatable to.
1478
+ #
1479
+ # source://json//lib/json/generic_object.rb#13
1480
+ def json_creatable=(_arg0); end
1481
+
1482
+ # @return [Boolean]
1483
+ #
1484
+ # source://json//lib/json/generic_object.rb#9
1485
+ def json_creatable?; end
1486
+
1487
+ # source://json//lib/json/generic_object.rb#15
1488
+ def json_create(data); end
1489
+
1490
+ # source://json//lib/json/generic_object.rb#36
1491
+ def load(source, proc = T.unsafe(nil), opts = T.unsafe(nil)); end
1492
+ end
1493
+ end
1494
+
1495
+ # The base exception for JSON errors.
1496
+ #
1497
+ # source://json//lib/json/common.rb#137
1498
+ class JSON::JSONError < ::StandardError
1499
+ class << self
1500
+ # source://json//lib/json/common.rb#138
1501
+ def wrap(exception); end
1502
+ end
1503
+ end
1504
+
1505
+ # source://json//lib/json/common.rb#35
1506
+ JSON::Parser = JSON::Ext::Parser
1507
+
1508
+ # source://json//lib/json/common.rb#73
1509
+ JSON::State = JSON::Ext::Generator::State
1510
+
1511
+ # For backwards compatibility
1512
+ #
1513
+ # source://json//lib/json/common.rb#159
1514
+ JSON::UnparserError = JSON::GeneratorError
1515
+
1516
+ # source://json//lib/json/common.rb#658
1517
+ module Kernel
1518
+ private
1519
+
1520
+ # If _object_ is string-like, parse the string and return the parsed result as
1521
+ # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
1522
+ # structure object and return it.
1523
+ #
1524
+ # The _opts_ argument is passed through to generate/parse respectively. See
1525
+ # generate and parse for their documentation.
1526
+ #
1527
+ # source://json//lib/json/common.rb#685
1528
+ def JSON(object, *args); end
1529
+
1530
+ # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
1531
+ # one line.
1532
+ #
1533
+ # source://json//lib/json/common.rb#663
1534
+ def j(*objs); end
1535
+
1536
+ # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
1537
+ # indentation and over many lines.
1538
+ #
1539
+ # source://json//lib/json/common.rb#672
1540
+ def jj(*objs); end
1541
+ end