json 1.7.1-java → 1.7.2-java

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

Potentially problematic release.


This version of json might be problematic. Click here for more details.

@@ -20,10 +20,13 @@ class Time
20
20
  # Returns a hash, that will be turned into a JSON object and represent this
21
21
  # object.
22
22
  def as_json(*)
23
+ nanoseconds = [ tv_usec * 1000 ]
24
+ respond_to?(:tv_nsec) and nanoseconds << tv_nsec
25
+ nanoseconds = nanoseconds.max
23
26
  {
24
27
  JSON.create_id => self.class.name,
25
28
  's' => tv_sec,
26
- 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
29
+ 'n' => nanoseconds,
27
30
  }
28
31
  end
29
32
 
@@ -103,7 +103,13 @@ module JSON
103
103
  MinusInfinity = -Infinity
104
104
 
105
105
  # The base exception for JSON errors.
106
- class JSONError < StandardError; end
106
+ class JSONError < StandardError
107
+ def self.wrap(exception)
108
+ obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
109
+ obj.set_backtrace exception.backtrace
110
+ obj
111
+ end
112
+ end
107
113
 
108
114
  # This exception is raised if a parser error occurs.
109
115
  class ParserError < JSONError; end
Binary file
Binary file
@@ -41,7 +41,6 @@ module JSON
41
41
  if defined?(::Encoding)
42
42
  def utf8_to_json(string) # :nodoc:
43
43
  string = string.dup
44
- string << '' # XXX workaround: avoid buffer sharing
45
44
  string.force_encoding(::Encoding::ASCII_8BIT)
46
45
  string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
47
46
  string.force_encoding(::Encoding::UTF_8)
@@ -50,9 +49,8 @@ module JSON
50
49
 
51
50
  def utf8_to_json_ascii(string) # :nodoc:
52
51
  string = string.dup
53
- string << '' # XXX workaround: avoid buffer sharing
54
52
  string.force_encoding(::Encoding::ASCII_8BIT)
55
- string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
53
+ string.gsub!(/["\\\x0-\x1f]/n) { MAP[$&] }
56
54
  string.gsub!(/(
57
55
  (?:
58
56
  [\xc2-\xdf][\x80-\xbf] |
@@ -63,16 +61,18 @@ module JSON
63
61
  )/nx) { |c|
64
62
  c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
65
63
  s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0]
64
+ s.force_encoding(::Encoding::ASCII_8BIT)
66
65
  s.gsub!(/.{4}/n, '\\\\u\&')
66
+ s.force_encoding(::Encoding::UTF_8)
67
67
  }
68
68
  string.force_encoding(::Encoding::UTF_8)
69
69
  string
70
70
  rescue => e
71
- raise GeneratorError, "Caught #{e.class}: #{e}"
71
+ raise GeneratorError.wrap(e)
72
72
  end
73
73
  else
74
74
  def utf8_to_json(string) # :nodoc:
75
- string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
75
+ string.gsub(/["\\\x0-\x1f]/n) { MAP[$&] }
76
76
  end
77
77
 
78
78
  def utf8_to_json_ascii(string) # :nodoc:
@@ -91,7 +91,7 @@ module JSON
91
91
  }
92
92
  string
93
93
  rescue => e
94
- raise GeneratorError, "Caught #{e.class}: #{e}"
94
+ raise GeneratorError.wrap(e)
95
95
  end
96
96
  end
97
97
  module_function :utf8_to_json, :utf8_to_json_ascii
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.7.1'
3
+ VERSION = '1.7.2'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.7.1
5
+ version: 1.7.2
6
6
  platform: java
7
7
  authors:
8
8
  - Daniel Luz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-05-07 00:00:00 Z
13
+ date: 2012-05-11 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: A JSON implementation as a JRuby extension.