oj 3.17.3 → 3.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/pages/Modes.md CHANGED
@@ -121,7 +121,7 @@ information.
121
121
  | :object_nl | String | | | x | x | | x | |
122
122
  | :omit_nil | Boolean | x | x | x | x | x | x | |
123
123
  | :quirks_mode | Boolean | | | 6 | | | x | |
124
- | :safe | String | | | x | | | | |
124
+ | :safe | Boolean | | | x | | | | |
125
125
  | :second_precision | Fixnum | | | | | x | x | |
126
126
  | :space | String | | | x | x | | x | |
127
127
  | :space_before | String | | | x | x | | x | |
data/pages/Options.md CHANGED
@@ -213,8 +213,7 @@ for json gem compatibility.
213
213
 
214
214
  Primary behavior for loading and dumping. The :mode option controls which
215
215
  other options are in effect. For more details see the {file:Modes.md} page. By
216
- default Oj uses the :custom mode which is provides the highest degree of
217
- customization.
216
+ default Oj uses the :object mode.
218
217
 
219
218
  ### :nan [Symbol]
220
219
 
@@ -249,6 +248,10 @@ integer gives better performance.
249
248
 
250
249
  If true, Hash and Object attributes with nil values are omitted.
251
250
 
251
+ ### :omit_null_byte [Boolean]
252
+
253
+ If true, null bytes in strings will be omitted when dumping.
254
+
252
255
  ### :quirks_mode [Boolean]
253
256
 
254
257
  Allow single JSON values instead of documents, default is true (allow). This
@@ -265,10 +268,6 @@ to true.
265
268
 
266
269
  The number of digits after the decimal when dumping the seconds of time.
267
270
 
268
- ### :skip_null_byte [Boolean]
269
-
270
- If true, null bytes in strings will be omitted when dumping.
271
-
272
271
  ### :space
273
272
 
274
273
  String inserted after the ':' character when dumping a JSON object. The
data/pages/Parser.md CHANGED
@@ -280,7 +280,7 @@ Oj::Parser.usual 0.452 110544.876
280
280
  JSON::Ext 1.009 49555.094
281
281
  ```
282
282
 
283
- The `Oj::Parser.new(:saj)` is **1.55** times faster than `Oj.load` and
283
+ The `Oj::Parser.new(:usual)` is **1.55** times faster than `Oj.load` and
284
284
  **2.23** times faster than the JSON gem.
285
285
 
286
286
  ### Object
@@ -298,7 +298,7 @@ Oj::Parser.usual 0.071 703502.033
298
298
  JSON::Ext 0.401 124638.859
299
299
  ```
300
300
 
301
- The `Oj::Parser.new(:saj)` is **3.17** times faster than
301
+ The `Oj::Parser.new(:usual)` is **3.17** times faster than
302
302
  `Oj.compat_load` and **5.64** times faster than the JSON gem.
303
303
 
304
304
  ## Summary
data/pages/Rails.md CHANGED
@@ -89,6 +89,12 @@ The classes that can be put in optimized mode and are optimized when
89
89
  * any class inheriting from ActiveRecord::Base
90
90
  * any other class where all attributes should be dumped
91
91
 
92
+ Both `Oj::Rails` and each `Oj::Rails::Encoder` have `optimize()`, `deoptimize()`, and `optimized?()` methods. The module level methods change the setting for the whole process. An encoder follows those process wide settings until `optimize()` or `deoptimize()` is called on the encoder itself. From then on the encoder keeps a set of its own and later module level changes do not reach it.
93
+
94
+ Options work the same way. An encoder reads `Oj.default_options` when it encodes, so later changes to the defaults reach it, unless it was given options of its own, in which case it keeps the copy it took when it was created. An encoder counts as having options of its own only if the hash it was built with names at least one option Oj knows. A hash of nothing but keys Oj does not have, such as the `escape: false` ActiveSupport 8.1 builds one of its cached encoders with, leaves the encoder on the defaults.
95
+
96
+ Once a class is optimized its `as_json()` method is no longer called, so an application that defines its own `as_json()` on an optimized class, `BigDecimal` for example, will not see it used. Call `Oj::Rails.deoptimize(BigDecimal)` after `Oj.optimize_rails` to put that one class back on the `as_json()` path and leave the rest optimized.
97
+
92
98
  The ActiveSupport decoder is the `JSON.parse()` method. Calling the
93
99
  `Oj::Rails.set_decoder()` method replaces that method with the Oj equivalent.
94
100
 
data/pages/Security.md CHANGED
@@ -11,10 +11,24 @@ auto defined is used with an untrusted source. The `Oj.safe_load()` method
11
11
  sets and uses the most strict and safest options. It should be used by
12
12
  developers who find it difficult to understand the options available in Oj.
13
13
 
14
- The options in Oj are designed to provide flexibility to the developer. This
15
- flexibility allows Objects to be serialized and deserialized. No methods are
16
- ever called on these created Objects but that does not stop the developer from
17
- calling methods on them. As in any system, check your inputs before working with
18
- them. Taking an arbitrary `String` from a user and evaluating it is never a good
19
- idea from an unsecure source. The same is true for `Object` attributes as they
20
- are not more than `String`s. Always check inputs from untrusted sources.
14
+ The options in Oj are designed to provide flexibility to the developer. This flexibility allows Objects to be serialized and deserialized. An Object is deserialized by allocating it without calling its initializer and then setting its instance variables. A few methods are called on what that builds: `exception` and `set_backtrace` on an `Exception`, and `replace` on a subclass of `Hash`, `Array` or `String` for a `self` key. As in any system, check your inputs before working with them. Taking an arbitrary `String` from a user and evaluating it is never a good idea from an unsecure source. The same is true for `Object` attributes as they are not more than `String`s. Always check inputs from untrusted sources.
15
+
16
+ ## The mode a document is loaded in
17
+
18
+ `Oj.load()` uses the `:object` mode unless the mode is changed. That mode takes the class of an Object from the document, so the document decides which of the classes already loaded in the process is allocated and what its instance variables are. Classes are looked up and not created unless `:auto_define` is turned on.
19
+
20
+ For a document from an untrusted source, ask for a mode that does not do that:
21
+
22
+ ```ruby
23
+ Oj.load(json, mode: :strict)
24
+ Oj.strict_load(json)
25
+ Oj.safe_load(json)
26
+ ```
27
+
28
+ or set it for the process:
29
+
30
+ ```ruby
31
+ Oj.default_options = {mode: :strict}
32
+ ```
33
+
34
+ `Oj.object_load()` is the explicit form of the current default and stays in `:object` mode whatever the default is set to.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.3
4
+ version: 3.17.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  - !ruby/object:Gem::Version
232
232
  version: '0'
233
233
  requirements: []
234
- rubygems_version: 4.0.3
234
+ rubygems_version: 4.0.17
235
235
  specification_version: 4
236
236
  summary: A fast JSON parser and serializer.
237
237
  test_files: []