yajl-ruby 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yajl-ruby might be problematic. Click here for more details.

data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.2 (August 25th, 2009)
4
+ * Fixed a bug surfaced by an existing library providing a to_json method, and Yajl would double-quote the values provided
5
+
3
6
  ## 0.6.1 (August 20th, 2009)
4
7
  * Fixed a bug in Yajl::HttpStream where responses contained multiple JSON strings but weren't Transfer-Encoding: chunked (thanks @dacort!)
5
8
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 6
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
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
- yajl_buf_append(g->buf, "\"", 1);
197
- yajl_string_encode(g->buf, str, len);
198
- yajl_buf_append(g->buf, "\"", 1);
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
@@ -13,7 +13,7 @@ require 'yajl_ext'
13
13
  #
14
14
  # Ruby bindings to the excellent Yajl (Yet Another JSON Parser) ANSI C library.
15
15
  module Yajl
16
- VERSION = "0.6.1"
16
+ VERSION = "0.6.2"
17
17
 
18
18
  class Parser
19
19
  # A helper method for parse-and-forget use-cases
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
3
3
 
4
4
  class Dummy2
5
5
  def to_json
6
- "hawtness"
6
+ '"hawtness"'
7
7
  end
8
8
  end
9
9
 
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.1"
8
+ s.version = "0.6.2"
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-20}
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: yajl-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
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-20 00:00:00 -07:00
13
+ date: 2009-08-25 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16