brianmario-yajl-ruby 0.6.1 → 0.6.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.
- data/CHANGELOG.md +6 -0
- data/VERSION.yml +1 -1
- data/benchmark/encode_json_and_yaml.rb +1 -1
- data/benchmark/parse_json_and_yaml.rb +1 -1
- data/ext/api/yajl_gen.h +2 -1
- data/ext/yajl_ext.c +4 -2
- data/ext/yajl_gen.c +9 -4
- data/lib/yajl.rb +1 -1
- data/lib/yajl/json_gem/encoding.rb +1 -1
- data/spec/encoding/encoding_spec.rb +1 -1
- data/spec/json_gem_compatibility/compatibility_spec.rb +4 -4
- data/yajl-ruby.gemspec +2 -2
- metadata +3 -4
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.6.3 (August 25th, 2009)
|
4
|
+
* Fixed a bug in the JSON gem compatibility API where strings weren't being properly escaped
|
5
|
+
|
6
|
+
## 0.6.2 (August 25th, 2009)
|
7
|
+
* Fixed a bug surfaced by an existing library providing a to_json method, and Yajl would double-quote the values provided
|
8
|
+
|
3
9
|
## 0.6.1 (August 20th, 2009)
|
4
10
|
* Fixed a bug in Yajl::HttpStream where responses contained multiple JSON strings but weren't Transfer-Encoding: chunked (thanks @dacort!)
|
5
11
|
|
data/VERSION.yml
CHANGED
data/ext/api/yajl_gen.h
CHANGED
@@ -96,7 +96,8 @@ extern "C" {
|
|
96
96
|
unsigned int len);
|
97
97
|
yajl_gen_status YAJL_API yajl_gen_string(yajl_gen hand,
|
98
98
|
const unsigned char * str,
|
99
|
-
unsigned int len
|
99
|
+
unsigned int len,
|
100
|
+
int quote);
|
100
101
|
yajl_gen_status YAJL_API yajl_gen_null(yajl_gen hand);
|
101
102
|
yajl_gen_status YAJL_API yajl_gen_bool(yajl_gen hand, int boolean);
|
102
103
|
yajl_gen_status YAJL_API yajl_gen_map_open(yajl_gen hand);
|
data/ext/yajl_ext.c
CHANGED
@@ -79,6 +79,7 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
|
|
79
79
|
int idx = 0;
|
80
80
|
const unsigned char * buffer;
|
81
81
|
unsigned int len;
|
82
|
+
int quote_strings = 1;
|
82
83
|
|
83
84
|
if (io != Qnil || w->on_progress_callback != Qnil) {
|
84
85
|
status = yajl_gen_get_buf(w->encoder, &buffer, &len);
|
@@ -135,15 +136,16 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
|
|
135
136
|
status = yajl_gen_number(w->encoder, RSTRING_PTR(str), (unsigned int)RSTRING_LEN(str));
|
136
137
|
break;
|
137
138
|
case T_STRING:
|
138
|
-
status = yajl_gen_string(w->encoder, (const unsigned char *)RSTRING_PTR(obj), (unsigned int)RSTRING_LEN(obj));
|
139
|
+
status = yajl_gen_string(w->encoder, (const unsigned char *)RSTRING_PTR(obj), (unsigned int)RSTRING_LEN(obj), 1);
|
139
140
|
break;
|
140
141
|
default:
|
141
142
|
if (rb_respond_to(obj, intern_to_json)) {
|
142
143
|
str = rb_funcall(obj, intern_to_json, 0);
|
144
|
+
quote_strings = 0; // this lets us append on to the buffer without Yajl quoting it again
|
143
145
|
} else {
|
144
146
|
str = rb_funcall(obj, intern_to_s, 0);
|
145
147
|
}
|
146
|
-
status = yajl_gen_string(w->encoder, (const unsigned char *)RSTRING_PTR(str), (unsigned int)RSTRING_LEN(str));
|
148
|
+
status = yajl_gen_string(w->encoder, (const unsigned char *)RSTRING_PTR(str), (unsigned int)RSTRING_LEN(str), quote_strings);
|
147
149
|
break;
|
148
150
|
}
|
149
151
|
}
|
data/ext/yajl_gen.c
CHANGED
@@ -190,12 +190,17 @@ yajl_gen_number(yajl_gen g, const char * s, unsigned int l)
|
|
190
190
|
|
191
191
|
yajl_gen_status
|
192
192
|
yajl_gen_string(yajl_gen g, const unsigned char * str,
|
193
|
-
unsigned int len)
|
193
|
+
unsigned int len, int quote)
|
194
194
|
{
|
195
195
|
ENSURE_VALID_STATE; INSERT_SEP; INSERT_WHITESPACE;
|
196
|
-
|
197
|
-
|
198
|
-
|
196
|
+
if (quote) {
|
197
|
+
yajl_buf_append(g->buf, "\"", 1);
|
198
|
+
yajl_string_encode(g->buf, str, len);
|
199
|
+
yajl_buf_append(g->buf, "\"", 1);
|
200
|
+
} else {
|
201
|
+
yajl_buf_append(g->buf, str, len);
|
202
|
+
}
|
203
|
+
|
199
204
|
APPENDED_ATOM;
|
200
205
|
FINAL_NEWLINE;
|
201
206
|
return yajl_gen_status_ok;
|
data/lib/yajl.rb
CHANGED
@@ -53,16 +53,16 @@ describe "JSON Gem compatability API" do
|
|
53
53
|
|
54
54
|
it "should encode arbitrary classes via their default to_json method" do
|
55
55
|
d = Dummy.new
|
56
|
-
d.to_json.should == "#{d.to_s}"
|
56
|
+
d.to_json.should == "\"#{d.to_s}\""
|
57
57
|
|
58
58
|
t = Time.now
|
59
|
-
t.to_json.should == "#{t.to_s}"
|
59
|
+
t.to_json.should == "\"#{t.to_s}\""
|
60
60
|
|
61
61
|
da = Date.today
|
62
|
-
da.to_json.should == "#{da.to_s}"
|
62
|
+
da.to_json.should == "\"#{da.to_s}\""
|
63
63
|
|
64
64
|
dt = DateTime.new
|
65
|
-
dt.to_json.should == "#{dt.to_s}"
|
65
|
+
dt.to_json.should == "\"#{dt.to_s}\""
|
66
66
|
end
|
67
67
|
|
68
68
|
context "ported tests for Unicode" do
|
data/yajl-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{yajl-ruby}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Lopez", "Lloyd Hilaiel"]
|
12
|
-
s.date = %q{2009-08-
|
12
|
+
s.date = %q{2009-08-25}
|
13
13
|
s.email = %q{seniorlopez@gmail.com}
|
14
14
|
s.extensions = ["ext/extconf.rb"]
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brianmario-yajl-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Lopez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-08-
|
13
|
+
date: 2009-08-25 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -162,7 +162,6 @@ files:
|
|
162
162
|
- yajl-ruby.gemspec
|
163
163
|
has_rdoc: false
|
164
164
|
homepage: http://github.com/brianmario/yajl-ruby
|
165
|
-
licenses:
|
166
165
|
post_install_message:
|
167
166
|
rdoc_options:
|
168
167
|
- --charset=UTF-8
|
@@ -184,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
183
|
requirements: []
|
185
184
|
|
186
185
|
rubyforge_project: yajl-ruby
|
187
|
-
rubygems_version: 1.
|
186
|
+
rubygems_version: 1.2.0
|
188
187
|
signing_key:
|
189
188
|
specification_version: 3
|
190
189
|
summary: Ruby C bindings to the excellent Yajl JSON stream-based parser library.
|