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.
- data/lib/json/add/time.rb +4 -1
- data/lib/json/common.rb +7 -1
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- data/lib/json/pure/generator.rb +6 -6
- data/lib/json/version.rb +1 -1
- metadata +2 -2
data/lib/json/add/time.rb
CHANGED
@@ -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' =>
|
29
|
+
'n' => nanoseconds,
|
27
30
|
}
|
28
31
|
end
|
29
32
|
|
data/lib/json/common.rb
CHANGED
@@ -103,7 +103,13 @@ module JSON
|
|
103
103
|
MinusInfinity = -Infinity
|
104
104
|
|
105
105
|
# The base exception for JSON errors.
|
106
|
-
class JSONError < StandardError
|
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
|
data/lib/json/ext/generator.jar
CHANGED
Binary file
|
data/lib/json/ext/parser.jar
CHANGED
Binary file
|
data/lib/json/pure/generator.rb
CHANGED
@@ -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
|
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
|
94
|
+
raise GeneratorError.wrap(e)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
module_function :utf8_to_json, :utf8_to_json_ascii
|
data/lib/json/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.7.
|
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-
|
13
|
+
date: 2012-05-11 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: A JSON implementation as a JRuby extension.
|