multi_json 1.8.2 → 1.8.3
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +15 -7
- data/CHANGELOG.md +5 -0
- data/Gemfile +14 -10
- data/README.md +1 -2
- data/lib/multi_json.rb +1 -1
- data/lib/multi_json/adapters/jr_jackson.rb +2 -0
- data/lib/multi_json/convertible_hash_keys.rb +17 -17
- data/lib/multi_json/version.rb +1 -1
- data/spec/shared/adapter.rb +22 -20
- metadata +22 -22
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df801671d8999a51f6f424a4021fb0ba92b02f5
|
4
|
+
data.tar.gz: 868ed7197a1c723fa44ad4dba0933abdb21224d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a256f92792b885140a950127425c9ead3c60d41fcea230ad81a9dfa053f0c7e01b55798b4b5db984ffb083a9116236c1c8dd3a0ecf5d951cca7f9f7ddc4f0c6d
|
7
|
+
data.tar.gz: 47be9e4bc4f779987890b995db6f5bfa5e98801e8f2e8c5c1def2fc3fdaa590bc91a42f74cb1fd4c750f4f6b44e7fa2963a43486b91cd1494be5939336bfc10d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
@@ -1,16 +1,24 @@
|
|
1
|
+
before_install:
|
2
|
+
- gem update bundler
|
3
|
+
- bundle --version
|
4
|
+
- gem update --system 2.1.11
|
5
|
+
- gem --version
|
1
6
|
bundler_args: --without development
|
2
7
|
language: ruby
|
3
8
|
rvm:
|
4
|
-
- rbx-18mode
|
5
|
-
- rbx-19mode
|
6
|
-
- jruby-18mode
|
7
|
-
- jruby-19mode
|
8
9
|
- 1.8.7
|
9
10
|
- 1.9.2
|
10
11
|
- 1.9.3
|
11
12
|
- 2.0.0
|
12
|
-
|
13
|
+
- 2.1.0
|
14
|
+
- jruby-18mode
|
15
|
+
- jruby-19mode
|
16
|
+
- jruby-head
|
17
|
+
- rbx
|
18
|
+
- ruby-head
|
13
19
|
matrix:
|
14
20
|
allow_failures:
|
15
|
-
- rvm: jruby-
|
16
|
-
- rvm:
|
21
|
+
- rvm: jruby-head
|
22
|
+
- rvm: rbx
|
23
|
+
- rvm: ruby-head
|
24
|
+
fast_finish: true
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
1.8.3
|
2
|
+
-----
|
3
|
+
* [Make JrJackson explicitly read StringIO objects](https://github.com/intridea/multi_json/commit/e1f162d5b668e5e4db5afa175361a601a8aa2b05)
|
4
|
+
* [Prevent calling #downcase on alias symbols](https://github.com/intridea/multi_json/commit/c1cf075453ce0110f7decc4f906444b1233bb67c)
|
5
|
+
|
1
6
|
1.8.2
|
2
7
|
-----
|
3
8
|
* [Downcase adapter string name for OS compatibility](https://github.com/intridea/multi_json/commit/b8e15a032247a63f1410d21a18add05035f3fa66)
|
data/Gemfile
CHANGED
@@ -6,16 +6,6 @@ gem 'yard', '>= 0.8'
|
|
6
6
|
gem 'json', '~> 1.4', :require => nil
|
7
7
|
gem 'json_pure', '~> 1.4', :require => nil
|
8
8
|
|
9
|
-
platforms :ruby, :mswin, :mingw do
|
10
|
-
gem 'oj', '~> 2.0', :require => nil
|
11
|
-
gem 'yajl-ruby', '~> 1.0', :require => nil
|
12
|
-
end
|
13
|
-
|
14
|
-
platforms :jruby do
|
15
|
-
gem 'gson', '>= 0.6', :require => nil
|
16
|
-
gem 'jrjackson', '~> 0.2.1', :require => nil
|
17
|
-
end
|
18
|
-
|
19
9
|
group :development do
|
20
10
|
gem 'kramdown', '>= 0.14'
|
21
11
|
gem 'pry'
|
@@ -27,4 +17,18 @@ group :test do
|
|
27
17
|
gem 'simplecov', :require => false
|
28
18
|
end
|
29
19
|
|
20
|
+
platforms :jruby do
|
21
|
+
gem 'gson', '>= 0.6', :require => nil
|
22
|
+
gem 'jrjackson', '~> 0.2.2', :require => nil
|
23
|
+
end
|
24
|
+
|
25
|
+
platforms :mingw, :mswin, :ruby do
|
26
|
+
gem 'oj', '~> 2.0', :require => nil
|
27
|
+
gem 'yajl-ruby', '~> 1.0', :require => nil
|
28
|
+
end
|
29
|
+
|
30
|
+
platforms :rbx do
|
31
|
+
gem 'rubysl', '~> 2.0'
|
32
|
+
end
|
33
|
+
|
30
34
|
gemspec
|
data/README.md
CHANGED
@@ -4,13 +4,11 @@
|
|
4
4
|
[][travis]
|
5
5
|
[][gemnasium]
|
6
6
|
[][codeclimate]
|
7
|
-
[][coveralls]
|
8
7
|
|
9
8
|
[gem]: https://rubygems.org/gems/multi_json
|
10
9
|
[travis]: http://travis-ci.org/intridea/multi_json
|
11
10
|
[gemnasium]: https://gemnasium.com/intridea/multi_json
|
12
11
|
[codeclimate]: https://codeclimate.com/github/intridea/multi_json
|
13
|
-
|
14
12
|
Lots of Ruby libraries parse JSON and everyone has their favorite JSON coder.
|
15
13
|
Instead of choosing a single JSON coder and forcing users of your library to be
|
16
14
|
stuck with it, you can use MultiJSON instead, which will simply choose the
|
@@ -62,6 +60,7 @@ implementations:
|
|
62
60
|
* Ruby 1.9.2
|
63
61
|
* Ruby 1.9.3
|
64
62
|
* Ruby 2.0.0
|
63
|
+
* Ruby 2.1.0
|
65
64
|
* [JRuby][]
|
66
65
|
* [Rubinius][]
|
67
66
|
* [MacRuby][] (not tested on Travis CI)
|
data/lib/multi_json.rb
CHANGED
@@ -2,40 +2,40 @@ module MultiJson
|
|
2
2
|
module ConvertibleHashKeys
|
3
3
|
private
|
4
4
|
|
5
|
-
def symbolize_keys(
|
6
|
-
|
5
|
+
def symbolize_keys(hash)
|
6
|
+
prepare_hash(hash) do |key|
|
7
7
|
key.respond_to?(:to_sym) ? key.to_sym : key
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def stringify_keys(
|
12
|
-
|
11
|
+
def stringify_keys(hash)
|
12
|
+
prepare_hash(hash) do |key|
|
13
13
|
key.respond_to?(:to_s) ? key.to_s : key
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
return
|
19
|
-
case
|
17
|
+
def prepare_hash(hash, &key_modifier)
|
18
|
+
return hash unless block_given?
|
19
|
+
case hash
|
20
20
|
when Array
|
21
|
-
|
22
|
-
|
21
|
+
hash.map do |value|
|
22
|
+
prepare_hash(value, &key_modifier)
|
23
23
|
end
|
24
24
|
when Hash
|
25
|
-
|
25
|
+
hash.inject({}) do |result, (key, value)|
|
26
26
|
new_key = key_modifier.call(key)
|
27
|
-
new_value =
|
27
|
+
new_value = prepare_hash(value, &key_modifier)
|
28
28
|
result.merge! new_key => new_value
|
29
29
|
end
|
30
30
|
when String, Numeric, true, false, nil
|
31
|
-
|
31
|
+
hash
|
32
32
|
else
|
33
|
-
if
|
34
|
-
|
35
|
-
elsif
|
36
|
-
|
33
|
+
if hash.respond_to?(:to_json)
|
34
|
+
hash
|
35
|
+
elsif hash.respond_to?(:to_s)
|
36
|
+
hash.to_s
|
37
37
|
else
|
38
|
-
|
38
|
+
hash
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/lib/multi_json/version.rb
CHANGED
@@ -2,7 +2,7 @@ module MultiJson
|
|
2
2
|
class Version
|
3
3
|
MAJOR = 1 unless defined? MultiJson::Version::MAJOR
|
4
4
|
MINOR = 8 unless defined? MultiJson::Version::MINOR
|
5
|
-
PATCH =
|
5
|
+
PATCH = 3 unless defined? MultiJson::Version::PATCH
|
6
6
|
PRE = nil unless defined? MultiJson::Version::PRE
|
7
7
|
|
8
8
|
class << self
|
data/spec/shared/adapter.rb
CHANGED
@@ -43,7 +43,7 @@ shared_examples_for 'an adapter' do |adapter|
|
|
43
43
|
{'abc' => 'def'},
|
44
44
|
[1, 2, 3, '4', true, false, nil]
|
45
45
|
].each do |example|
|
46
|
-
expect(MultiJson.load(MultiJson.dump(example))).to eq
|
46
|
+
expect(MultiJson.load(MultiJson.dump(example))).to eq(example)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -57,7 +57,7 @@ shared_examples_for 'an adapter' do |adapter|
|
|
57
57
|
else
|
58
58
|
'Tue Dec 11 09:39:05 UTC 2012'
|
59
59
|
end
|
60
|
-
expect(MultiJson.load(dumped_json)).to eq
|
60
|
+
expect(MultiJson.load(dumped_json)).to eq(expected)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -81,13 +81,13 @@ shared_examples_for 'an adapter' do |adapter|
|
|
81
81
|
]
|
82
82
|
].each do |example, expected|
|
83
83
|
dumped_json = MultiJson.dump(example)
|
84
|
-
expect(MultiJson.load(dumped_json)).to eq
|
84
|
+
expect(MultiJson.load(dumped_json)).to eq(expected)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'dumps rootless JSON' do
|
89
|
-
expect(MultiJson.dump('random rootless string')).to eq
|
90
|
-
expect(MultiJson.dump(123)).to eq
|
89
|
+
expect(MultiJson.dump('random rootless string')).to eq('"random rootless string"')
|
90
|
+
expect(MultiJson.dump(123)).to eq('123')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'passes options to the adapter' do
|
@@ -95,21 +95,18 @@ shared_examples_for 'an adapter' do |adapter|
|
|
95
95
|
MultiJson.dump('foo', :bar => :baz)
|
96
96
|
end
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
def to_json(*)
|
104
|
-
'"foobar"'
|
105
|
-
end
|
98
|
+
it 'dumps custom objects that implement to_json' do
|
99
|
+
pending 'not supported' if adapter.name == 'MultiJson::Adapters::Gson'
|
100
|
+
klass = Class.new do
|
101
|
+
def to_json(*)
|
102
|
+
'"foobar"'
|
106
103
|
end
|
107
|
-
expect(MultiJson.dump(klass.new)).to eq '"foobar"'
|
108
104
|
end
|
105
|
+
expect(MultiJson.dump(klass.new)).to eq('"foobar"')
|
109
106
|
end
|
110
107
|
|
111
108
|
it 'allows to dump JSON values' do
|
112
|
-
expect(MultiJson.dump(42)).to eq
|
109
|
+
expect(MultiJson.dump(42)).to eq('42')
|
113
110
|
end
|
114
111
|
|
115
112
|
it 'allows to dump JSON with UTF-8 characters' do
|
@@ -167,6 +164,11 @@ shared_examples_for 'an adapter' do |adapter|
|
|
167
164
|
|
168
165
|
it 'raises MultiJson::LoadError on blank input or invalid input' do
|
169
166
|
[nil, '{"abc"}', ' ', "\t\t\t", "\n", "\x82\xAC\xEF"].each do |input|
|
167
|
+
if input == "\x82\xAC\xEF"
|
168
|
+
pending 'GSON bug: https://github.com/avsej/gson.rb/issues/3' if adapter.name =~ /Gson/
|
169
|
+
pending 'JrJackson bug: https://github.com/guyboertje/jrjackson/issues/21' if adapter.name =~ /JrJackson/
|
170
|
+
end
|
171
|
+
|
170
172
|
expect{MultiJson.load(input)}.to raise_error(MultiJson::LoadError)
|
171
173
|
end
|
172
174
|
end
|
@@ -176,7 +178,7 @@ shared_examples_for 'an adapter' do |adapter|
|
|
176
178
|
begin
|
177
179
|
MultiJson.load(data)
|
178
180
|
rescue MultiJson::LoadError => le
|
179
|
-
expect(le.data).to eq
|
181
|
+
expect(le.data).to eq(data)
|
180
182
|
end
|
181
183
|
end
|
182
184
|
|
@@ -185,7 +187,7 @@ shared_examples_for 'an adapter' do |adapter|
|
|
185
187
|
begin
|
186
188
|
MultiJson.load(data)
|
187
189
|
rescue MultiJson::DecodeError => de
|
188
|
-
expect(de.data).to eq
|
190
|
+
expect(de.data).to eq(data)
|
189
191
|
end
|
190
192
|
end
|
191
193
|
|
@@ -213,14 +215,14 @@ shared_examples_for 'an adapter' do |adapter|
|
|
213
215
|
[
|
214
216
|
'{"abc":[{"def":"hgi"}]}',
|
215
217
|
{:abc => [{:def => 'hgi'}]},
|
216
|
-
]
|
218
|
+
]
|
217
219
|
].each do |example, expected|
|
218
|
-
expect(MultiJson.load(example, :symbolize_keys => true)).to eq
|
220
|
+
expect(MultiJson.load(example, :symbolize_keys => true)).to eq(expected)
|
219
221
|
end
|
220
222
|
end
|
221
223
|
|
222
224
|
it 'allows to load JSON values' do
|
223
|
-
expect(MultiJson.load('42')).to eq
|
225
|
+
expect(MultiJson.load('42')).to eq(42)
|
224
226
|
end
|
225
227
|
|
226
228
|
it 'allows to load JSON with UTF-8 characters' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
7BTxdlSpJZDcAK29Ni3NRCRu6Air4wfDln0Ilzeuut6cJ4/j2/RlvsccVSRaEfOa
|
34
34
|
wM7GTK5SEdU3qelyBdc4+RRs6uU=
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date:
|
36
|
+
date: 2014-01-09 00:00:00.000000000 Z
|
37
37
|
dependencies:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: bundler
|
@@ -60,30 +60,17 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- .document
|
64
|
+
- .rspec
|
65
|
+
- .travis.yml
|
63
66
|
- .yardopts
|
64
67
|
- CHANGELOG.md
|
65
68
|
- CONTRIBUTING.md
|
69
|
+
- Gemfile
|
66
70
|
- LICENSE.md
|
67
71
|
- README.md
|
68
72
|
- Rakefile
|
69
|
-
- multi_json.
|
70
|
-
- Gemfile
|
71
|
-
- .document
|
72
|
-
- .rspec
|
73
|
-
- .travis.yml
|
74
|
-
- spec/gson_adapter_spec.rb
|
75
|
-
- spec/jr_jackson_adapter_spec.rb
|
76
|
-
- spec/json_gem_adapter_spec.rb
|
77
|
-
- spec/json_pure_adapter_spec.rb
|
78
|
-
- spec/multi_json_spec.rb
|
79
|
-
- spec/nsjsonserialization_adapter_spec.rb
|
80
|
-
- spec/oj_adapter_spec.rb
|
81
|
-
- spec/ok_json_adapter_spec.rb
|
82
|
-
- spec/shared/adapter.rb
|
83
|
-
- spec/shared/json_common_adapter.rb
|
84
|
-
- spec/shared/options.rb
|
85
|
-
- spec/spec_helper.rb
|
86
|
-
- spec/yajl_adapter_spec.rb
|
73
|
+
- lib/multi_json.rb
|
87
74
|
- lib/multi_json/adapter.rb
|
88
75
|
- lib/multi_json/adapters/gson.rb
|
89
76
|
- lib/multi_json/adapters/jr_jackson.rb
|
@@ -99,7 +86,20 @@ files:
|
|
99
86
|
- lib/multi_json/options.rb
|
100
87
|
- lib/multi_json/vendor/okjson.rb
|
101
88
|
- lib/multi_json/version.rb
|
102
|
-
-
|
89
|
+
- multi_json.gemspec
|
90
|
+
- spec/gson_adapter_spec.rb
|
91
|
+
- spec/jr_jackson_adapter_spec.rb
|
92
|
+
- spec/json_gem_adapter_spec.rb
|
93
|
+
- spec/json_pure_adapter_spec.rb
|
94
|
+
- spec/multi_json_spec.rb
|
95
|
+
- spec/nsjsonserialization_adapter_spec.rb
|
96
|
+
- spec/oj_adapter_spec.rb
|
97
|
+
- spec/ok_json_adapter_spec.rb
|
98
|
+
- spec/shared/adapter.rb
|
99
|
+
- spec/shared/json_common_adapter.rb
|
100
|
+
- spec/shared/options.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- spec/yajl_adapter_spec.rb
|
103
103
|
homepage: http://github.com/intridea/multi_json
|
104
104
|
licenses:
|
105
105
|
- MIT
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: 1.3.5
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.2.0
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: A common interface to multiple JSON libraries.
|
metadata.gz.sig
CHANGED
Binary file
|