oj 3.13.3 → 3.13.4

Sign up to get free protection for your applications and to get access to all the features.
data/test/big.rb ADDED
@@ -0,0 +1,15 @@
1
+ #require 'active_support'
2
+ #require 'active_support/core_ext'
3
+ #require 'active_support/json'
4
+ require 'oj'
5
+
6
+ #Oj.optimize_rails
7
+ Oj.mimic_JSON
8
+
9
+ h = {:type=>:record, :name=>:group, :namespace=>"com.salsify.identity", :fields=>[{:name=>"id", :type=>{:name=>:salsify_uuid, :type=>:fixed, :namespace=>"com.salsify", :size=>38}}, {:name=>"type", :type=>"string", :default=>"groups"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"name", :type=>"string"}, {:name=>"policy", :type=>[:null, {:type=>:record, :name=>:policy, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"policies"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"name", :type=>"string"}, {:name=>"statements", :type=>{:type=>:array, :items=>{:type=>:record, :name=>:statement, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"statements"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"action", :type=>{:name=>"__statement_action_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:manage, :read]}}, {:name=>"resource", :type=>{:name=>"__statement_resource_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:product, :digital_asset]}}, {:name=>"conditions", :type=>{:type=>:array, :items=>{:type=>:record, :name=>:condition, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"conditions"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"operator", :type=>{:name=>"__condition_operator_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:equals]}}, {:name=>"attribute_type", :type=>{:name=>"__condition_attribute_type_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:resource]}}, {:name=>"value", :type=>"string"}, {:name=>"attribute", :type=>[:null, {:type=>:record, :name=>:reference, :namespace=>"com.salsify", :fields=>[{:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :doc=>"snake_case, plural name for the resource type"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}]}], :default=>nil}, {:name=>"broken", :type=>[:null, "boolean"], :default=>nil}]}}}]}}}]}], :default=>nil}]}
10
+
11
+ #Oj.dump(h)
12
+ puts JSON.pretty_generate(h)
13
+ #puts JSON.fast_generate(h)
14
+ #puts JSON.generate(h)
15
+
data/test/foo.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << File.dirname(__FILE__)
4
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
5
- %w(lib ext).each do |dir|
6
- $: << File.join($oj_dir, dir)
7
- end
3
+ $: << '.'
4
+ $: << '../lib'
5
+ $: << '../ext'
8
6
 
9
7
  require 'oj'
10
8
 
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ %w(lib ext test).each do |dir|
5
+ $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
6
+ end
7
+
8
+ require 'oj'
9
+
10
+ json =<<-EOF
11
+ {
12
+ "$id": "https://example.com/person.schema.json",
13
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
14
+ "title": "Person",
15
+ "type": "object",
16
+ "properties": {
17
+ "firstName": {
18
+ "type": "string",
19
+ "description": "The person's first name."
20
+ },
21
+ "lastName": {
22
+ "type": "string",
23
+ "description": "The person's last name."
24
+ },
25
+ "age": {
26
+ "description": "Age in years which must be equal to or greater than zero.",
27
+ "type": "integer",
28
+ "minimum": 0
29
+ }
30
+ }
31
+ }
32
+ EOF
33
+
34
+ #json = '{"abc": true}'
35
+ #json = '[true,false]'
36
+
37
+ 100_001.times do |i|
38
+ p = Oj::Parser.new(:usual).parse(json)
39
+
40
+ if i % 10_000 == 0
41
+ GC.start
42
+ rss = Integer(`ps -o rss= -p #{Process.pid}`) / 1024.0
43
+ puts "#{i},#{rss} MB"
44
+ end
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.3
4
+ version: 3.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-30 00:00:00.000000000 Z
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -91,6 +91,7 @@ extra_rdoc_files:
91
91
  - pages/Security.md
92
92
  - pages/WAB.md
93
93
  files:
94
+ - CHANGELOG.md
94
95
  - LICENSE
95
96
  - README.md
96
97
  - ext/oj/buf.h
@@ -194,8 +195,8 @@ files:
194
195
  - test/activesupport6/test_common.rb
195
196
  - test/activesupport6/test_helper.rb
196
197
  - test/activesupport6/time_zone_test_helpers.rb
197
- - test/bar.rb
198
- - test/baz.rb
198
+ - test/benny.rb
199
+ - test/big.rb
199
200
  - test/files.rb
200
201
  - test/foo.rb
201
202
  - test/helper.rb
@@ -231,7 +232,6 @@ files:
231
232
  - test/perf_simple.rb
232
233
  - test/perf_strict.rb
233
234
  - test/perf_wab.rb
234
- - test/prec.rb
235
235
  - test/sample.rb
236
236
  - test/sample/change.rb
237
237
  - test/sample/dir.rb
@@ -258,6 +258,7 @@ files:
258
258
  - test/test_null.rb
259
259
  - test/test_object.rb
260
260
  - test/test_parser.rb
261
+ - test/test_parser_memory.rb
261
262
  - test/test_parser_saj.rb
262
263
  - test/test_parser_usual.rb
263
264
  - test/test_rails.rb
@@ -270,7 +271,6 @@ files:
270
271
  - test/tests.rb
271
272
  - test/tests_mimic.rb
272
273
  - test/tests_mimic_addition.rb
273
- - test/zoo.rb
274
274
  homepage: http://www.ohler.com/oj
275
275
  licenses:
276
276
  - MIT
@@ -281,7 +281,7 @@ metadata:
281
281
  homepage_uri: http://www.ohler.com/oj/
282
282
  source_code_uri: https://github.com/ohler55/oj
283
283
  wiki_uri: https://github.com/ohler55/oj/wiki
284
- post_install_message:
284
+ post_install_message:
285
285
  rdoc_options:
286
286
  - "--title"
287
287
  - Oj
@@ -301,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  version: '0'
302
302
  requirements: []
303
303
  rubygems_version: 3.2.22
304
- signing_key:
304
+ signing_key:
305
305
  specification_version: 4
306
306
  summary: A fast JSON parser and serializer.
307
307
  test_files:
@@ -325,8 +325,8 @@ test_files:
325
325
  - test/activesupport6/test_common.rb
326
326
  - test/activesupport6/test_helper.rb
327
327
  - test/activesupport6/time_zone_test_helpers.rb
328
- - test/bar.rb
329
- - test/baz.rb
328
+ - test/benny.rb
329
+ - test/big.rb
330
330
  - test/files.rb
331
331
  - test/foo.rb
332
332
  - test/helper.rb
@@ -362,7 +362,6 @@ test_files:
362
362
  - test/perf_simple.rb
363
363
  - test/perf_strict.rb
364
364
  - test/perf_wab.rb
365
- - test/prec.rb
366
365
  - test/sample/change.rb
367
366
  - test/sample/dir.rb
368
367
  - test/sample/doc.rb
@@ -389,6 +388,7 @@ test_files:
389
388
  - test/test_null.rb
390
389
  - test/test_object.rb
391
390
  - test/test_parser.rb
391
+ - test/test_parser_memory.rb
392
392
  - test/test_parser_saj.rb
393
393
  - test/test_parser_usual.rb
394
394
  - test/test_rails.rb
@@ -401,4 +401,3 @@ test_files:
401
401
  - test/tests.rb
402
402
  - test/tests_mimic.rb
403
403
  - test/tests_mimic_addition.rb
404
- - test/zoo.rb
data/test/bar.rb DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << File.dirname(__FILE__)
4
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
5
- %w(lib ext).each do |dir|
6
- $: << File.join($oj_dir, dir)
7
- end
8
-
9
- require 'active_support'
10
- require "active_support/json"
11
-
12
- $s = "\u2014 & \n \u{1F618}"
13
-
14
- =begin
15
- def check(label)
16
- puts "\n--- #{label} --------------------"
17
-
18
- ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
19
- puts "with standard_json == true: t.to_json - #{$t.to_json}"
20
- ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
21
- puts "with standard_json == false: t.to_json - #{$t.to_json}"
22
- end
23
-
24
- check('Before Oj')
25
- =end
26
-
27
- require 'oj'
28
-
29
- ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false
30
- puts "ActiveSupport.encode(s) - #{ActiveSupport::JSON.encode($s)}"
31
-
32
- Oj.optimize_rails
33
- Oj.default_options = { mode: :rails }
34
-
35
- puts "Oj.dump(s) - #{Oj.dump($s)}"
data/test/baz.rb DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << File.dirname(__FILE__)
4
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
5
- %w(lib ext).each do |dir|
6
- $: << File.join($oj_dir, dir)
7
- end
8
-
9
- require 'oj'
10
- Oj.mimic_JSON()
11
-
12
- begin
13
- ::JSON.load('name=&email=&subject=&comment=&submit=Send+Message')
14
- rescue ::JSON::ParserError
15
- puts "*** Pass"
16
- end
data/test/prec.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'oj'
4
-
5
- extras = {"locationLng" => -97.14690769100295}
6
-
7
- Oj.default_options = {float_precision: 17}
8
-
9
- encoded = Oj.dump(extras)
10
- puts encoded
11
- puts Oj.load(encoded)
12
-
13
- require "active_record"
14
-
15
- Oj::Rails.set_encoder()
16
- Oj::Rails.set_decoder()
17
-
18
- Oj.default_options = {float_precision: 17}
19
- # Using Oj rails encoder, gets the correct value: {"locationLng":-97.14690769100295}
20
- encoded = ActiveSupport::JSON.encode(extras)
21
- puts encoded
22
- puts ActiveSupport::JSON.decode(encoded)
23
- puts Oj.load(encoded)
data/test/zoo.rb DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #require 'json'
4
-
5
- $: << File.dirname(__FILE__)
6
- require 'helper'
7
- require 'oj'
8
-
9
- Oj.mimic_JSON
10
- puts "\u3074"
11
-
12
- puts JSON.dump(["\u3074"])
13
- puts JSON.generate(["\u3074"])