checkoff 0.223.0 → 0.225.0

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