rufus-json 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,5 +2,10 @@
2
2
  = rufus-json CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-json - 0.2.0 released 2010/02/08
6
+
7
+ - JSON :max_nesting set to nil (no limits)
8
+
9
+
5
10
  == rufus-json - 0.1.0 released 2009/12/25
6
11
 
data/README.rdoc CHANGED
@@ -3,11 +3,15 @@
3
3
 
4
4
  One interface for various JSON Ruby backends.
5
5
 
6
+ require 'rubygems'
7
+
6
8
  # load your favourite JSON backend
7
9
  require 'yajl'
8
10
  #require 'json'
9
11
  #require 'active_support'
10
12
 
13
+ require 'rufus-json' # gem install rufus-json
14
+
11
15
  p Rufus::Json.decode('{"a":2,"b":true}')
12
16
  # => { 'a' => 2, 'b' => true }
13
17
 
data/lib/rufus/json.rb CHANGED
@@ -26,13 +26,13 @@
26
26
  module Rufus
27
27
  module Json
28
28
 
29
- VERSION = '0.1.0'
29
+ VERSION = '0.2.0'
30
30
 
31
31
  # The JSON / JSON pure decoder
32
32
  #
33
33
  JSON = [
34
34
  lambda { |o| o.to_json },
35
- lambda { |s| ::JSON.parse(s) }
35
+ lambda { |s| ::JSON.parse(s, :max_nesting => nil) }
36
36
  ]
37
37
 
38
38
  # The Rails ActiveSupport::JSON decoder
data/rufus-json.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rufus-json}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux"]
12
- s.date = %q{2009-12-25}
12
+ s.date = %q{2010-02-08}
13
13
  s.description = %q{
14
14
  One interface to various JSON ruby libs (yajl, json, json_pure, json-jruby, active_support). Has a preference for yajl.
15
15
  }
@@ -27,6 +27,7 @@ One interface to various JSON ruby libs (yajl, json, json_pure, json-jruby, acti
27
27
  "lib/rufus-json.rb",
28
28
  "lib/rufus/json.rb",
29
29
  "rufus-json.gemspec",
30
+ "test/nesting20.rb",
30
31
  "test/test.rb"
31
32
  ]
32
33
  s.homepage = %q{http://github.com/jmettraux/rufus-json/}
data/test/nesting20.rb ADDED
@@ -0,0 +1,22 @@
1
+
2
+ require 'rubygems'
3
+ require 'json'
4
+
5
+ puts `ruby -v`
6
+ puts `gem search json`
7
+
8
+ h = {}
9
+ p = h
10
+ (1..21).each do |i|
11
+ p['a'] = {}
12
+ p = p['a']
13
+ end
14
+
15
+ s = h.to_json
16
+
17
+ p s
18
+
19
+ h = JSON.parse(s, :max_nesting => 100)
20
+
21
+ p h
22
+
data/test/test.rb CHANGED
@@ -61,6 +61,11 @@ class JsonTest < Test::Unit::TestCase
61
61
  do_test_dup('json', Rufus::Json::JSON)
62
62
  end
63
63
 
64
+ def test_deep_nesting_json
65
+
66
+ do_test_deep_nesting('json', Rufus::Json::JSON)
67
+ end
68
+
64
69
  def test_decode_yajl
65
70
 
66
71
  do_test_decode('yajl', Rufus::Json::YAJL)
@@ -76,6 +81,11 @@ class JsonTest < Test::Unit::TestCase
76
81
  do_test_dup('yajl', Rufus::Json::YAJL)
77
82
  end
78
83
 
84
+ def test_deep_nesting_yajl
85
+
86
+ do_test_deep_nesting('yajl', Rufus::Json::YAJL)
87
+ end
88
+
79
89
  def test_decode_as
80
90
 
81
91
  do_test_decode('active_support', Rufus::Json::ACTIVE)
@@ -91,6 +101,11 @@ class JsonTest < Test::Unit::TestCase
91
101
  do_test_dup('active_support', Rufus::Json::ACTIVE)
92
102
  end
93
103
 
104
+ def test_deep_nesting_as
105
+
106
+ do_test_deep_nesting('active_support', Rufus::Json::ACTIVE)
107
+ end
108
+
94
109
  protected
95
110
 
96
111
  def do_test_decode (lib, cons)
@@ -129,5 +144,23 @@ class JsonTest < Test::Unit::TestCase
129
144
  assert_equal({ 'id' => 'nada' }, Rufus::Json.dup(d0))
130
145
  assert_equal({ 'id' => 'nada' }, Rufus::Json.dup(d1))
131
146
  end
147
+
148
+ def do_test_deep_nesting (lib, cons)
149
+
150
+ require lib
151
+ Rufus::Json.backend = cons
152
+
153
+ s = "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{}}}}}}}}}}}}}}}}}}}}}}"
154
+
155
+ h = {}
156
+ p = h
157
+ (1..21).each do |i|
158
+ p['a'] = {}
159
+ p = p['a']
160
+ end
161
+
162
+ assert_equal(s, Rufus::Json.encode(h))
163
+ assert_equal(h, Rufus::Json.decode(s))
164
+ end
132
165
  end
133
166
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-25 00:00:00 +09:00
12
+ date: 2010-02-08 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - lib/rufus-json.rb
72
72
  - lib/rufus/json.rb
73
73
  - rufus-json.gemspec
74
+ - test/nesting20.rb
74
75
  - test/test.rb
75
76
  has_rdoc: true
76
77
  homepage: http://github.com/jmettraux/rufus-json/