oj 3.10.1 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dd1cae4ccf720f35b777913213b66466c7d9752055c60d828cdf681956731a3
4
- data.tar.gz: e913c57a4619bfbea97144f6f4783219aca294e598c8c6449ddfc6cb997b46f7
3
+ metadata.gz: '0569d0892b3b9d79f0edf0866d843adb9abc21046838be295164884edb930b61'
4
+ data.tar.gz: ff04edae94da97c911b19c93015035df9fb3ce89162c0afc1df036e0f675e65f
5
5
  SHA512:
6
- metadata.gz: dc0b7bd0e9ea90e69eda6a6205c09540e2217f9ccdcb3c6e937fb82e4b979fada30a028b64559ac5dfddc22afb9d4302669de35315bb5c5392ad100a373bb472
7
- data.tar.gz: 8d8ad9eeb68fb2d058c3f499ad51fc8c50d3349b36a237769f996a43de58449fbae36d3bff82c6be6a16828331f12aa19df6a1ef90b5bdff78ecdf732450a268
6
+ metadata.gz: 2d5a28e21b6c37bc5a11917512906c040cf8a0b038a07f23c0447a1705986fe98803191f6d2462e4f0ec67f7f3694cd9c61d0149d782f0a5e5f6b6d36a88d372
7
+ data.tar.gz: 789c0fdfe061476ee5e5c4bbe84519e7b1a6a015436e7fbe2cdb5f7922d6eef8de5914bd61488be4c297633e053f2a217630f7358796de9ba746aa6935466983
@@ -669,7 +669,8 @@ static void
669
669
  array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) {
670
670
  volatile VALUE rval = Qnil;
671
671
 
672
- if (3 <= len && 0 != pi->circ_array) {
672
+ // orig lets us know whether the string was ^r1 or \u005er1
673
+ if (3 <= len && 0 != pi->circ_array && '^' == orig[0] && 0 == rb_array_len(stack_peek(&pi->stack)->val)) {
673
674
  if ('i' == str[1]) {
674
675
  long i = read_long(str + 2, len - 2);
675
676
 
@@ -1041,6 +1041,12 @@ CLEANUP:
1041
1041
  if (pi->str_rx.head != oj_default_options.str_rx.head) {
1042
1042
  oj_rxclass_cleanup(&pi->str_rx);
1043
1043
  }
1044
+ // TBD if validate only then (Qundef == result ??)
1045
+ // if pi->err or 0 != line
1046
+ // rb_get_errinfo();??
1047
+ // rb_set_errinfo(Qnil);
1048
+ // return nil or error
1049
+
1044
1050
  if (err_has(&pi->err)) {
1045
1051
  rb_set_errinfo(Qnil);
1046
1052
  if (Qnil != pi->err_class) {
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.10.1'
4
+ VERSION = '3.10.2'
5
5
  end
@@ -80,6 +80,44 @@ The classes that can be put in optimized mode and are optimized when
80
80
  The ActiveSupport decoder is the `JSON.parse()` method. Calling the
81
81
  `Oj::Rails.set_decoder()` method replaces that method with the Oj equivalent.
82
82
 
83
+ ### Usage in Rails 3
84
+
85
+ To support Rails 3 you can create a new module mixin to prepend to controllers:
86
+
87
+ ```ruby
88
+ require 'oj'
89
+
90
+ module OjJsonEncoder
91
+ def render(options = nil, extra_options = {}, &block)
92
+ if options && options[:json]
93
+ obj = options.delete(:json)
94
+ options[:text] = Oj.dump(obj, :mode => :rails)
95
+ options[:content_type] = 'application/json'
96
+ end
97
+ super
98
+ end
99
+ end
100
+ ```
101
+
102
+ Usage:
103
+
104
+ ```ruby
105
+ class MyController < ApplicationController
106
+ prepend OjJsonEncoder
107
+ def index
108
+ render :json => { :hello => 'world' }
109
+ end
110
+ end
111
+ ```
112
+
113
+ ### Older Ruby Version Support (Pre 2.3.0)
114
+
115
+ If you are using an older version of Ruby, you can pin `oj` to an earlier version in your Gemfile:
116
+
117
+ ```ruby
118
+ gem 'oj', '3.7.12'
119
+ ```
120
+
83
121
  ### Notes:
84
122
 
85
123
  1. Optimized Floats set the significant digits to 16. This is different than
@@ -869,6 +869,14 @@ class ObjectJuice < Minitest::Test
869
869
  assert_equal(a2[1].__id__, a2.__id__)
870
870
  end
871
871
 
872
+ def test_circular_array3
873
+ a = ['^r1']
874
+ json = Oj.dump(a, mode: :object, circular: true)
875
+ assert_equal(%{["^i1","\\u005er1"]}, json)
876
+ a2 = Oj.load(json, mode: :object, circular: true)
877
+ assert_equal(a, a2)
878
+ end
879
+
872
880
  def test_circular_hash2
873
881
  h = { 'a' => 7 }
874
882
  h['b'] = h
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.10.1
4
+ version: 3.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  - !ruby/object:Gem::Version
284
284
  version: '0'
285
285
  requirements: []
286
- rubygems_version: 3.0.3
286
+ rubygems_version: 3.1.2
287
287
  signing_key:
288
288
  specification_version: 4
289
289
  summary: A fast JSON parser and serializer.