jrjackson 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +60 -25
- data/changelog.md +4 -0
- data/lib/jrjackson/build_info.rb +2 -2
- data/lib/jrjackson/jars/jrjackson-1.2.16.jar +0 -0
- data/src/main/java/com/jrjackson/RubyAnySerializer.java +6 -3
- data/src/main/java/com/jrjackson/RubyDateFormat.java +0 -2
- data/test/jrjackson_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549f6826999b9654a348daa2aaed4d80cdcd4014
|
4
|
+
data.tar.gz: ec6bc1ae63c834ee2a7c6ddfc6718f6b89897996
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a4c411e0caea3b5b83216382a7446a8eec67cfdded758b8b9b9377ce7b26d7ec6d09f262f39f6f5307acf5bbb5fcb0763e74bdffa7adc29c11405deea7bd0f4
|
7
|
+
data.tar.gz: 3ee2f6c6b9cb930db62214fb66efb495c6505fb209ae7232c509c544ff5fb97e2daa0c04af3e9840858e04d4a1b48260e8dce1f2991e06024e8f45f7623d062c
|
data/README.md
CHANGED
@@ -12,18 +12,25 @@ __NOTE:__ Smile support has been temporarily dropped
|
|
12
12
|
|
13
13
|
The code has been refactored to use almost all Java.
|
14
14
|
|
15
|
-
There is now a MultiJson adapter added for JrJackson
|
15
|
+
There is now a MultiJson adapter added for JrJackson.
|
16
|
+
|
17
|
+
This release is compatible with JRuby 9.0.0.0 and higher.
|
16
18
|
|
17
19
|
***
|
18
20
|
|
19
21
|
#### NEWS
|
20
22
|
|
23
|
+
13th September 2015 - added support for a `to_json_data` method lookup.
|
24
|
+
Use this if you want to provide a JSON native data structure that best
|
25
|
+
represents your custom object.
|
26
|
+
|
21
27
|
11th May 2014 - Added to_time method call for Ruby object serialization
|
22
28
|
|
23
29
|
26th October 2013 - Added support to serialize arbitary (non JSON datatypes)
|
24
30
|
ruby objects. Normally the toJava internal method is called, but additionally
|
25
31
|
to_h, to_hash, to_a and finally to_json are tried. Be aware that the to_json
|
26
|
-
method might invoke a new selialization session
|
32
|
+
method might invoke a new selialization session (i.e. it may use the JSON gem)
|
33
|
+
and impact performance.
|
27
34
|
|
28
35
|
***
|
29
36
|
|
@@ -43,7 +50,7 @@ The options hash respects three symbol keys
|
|
43
50
|
+ :raw
|
44
51
|
|
45
52
|
Will return JRuby wrapped java objects that quack like ruby objects
|
46
|
-
This is the fastest option
|
53
|
+
This is the fastest option but not by much
|
47
54
|
|
48
55
|
+ :use_bigdecimal
|
49
56
|
|
@@ -51,6 +58,10 @@ The options hash respects three symbol keys
|
|
51
58
|
If used with the :raw option you will get Java::JavaMath::BigDecimal objects
|
52
59
|
otherwise they are Ruby BigDecimal
|
53
60
|
|
61
|
+
+ :use_smallint
|
62
|
+
|
63
|
+
Will return Integers objects instead of BigInteger
|
64
|
+
|
54
65
|
```
|
55
66
|
JrJackson::Json.dump(obj) -> json string
|
56
67
|
aliased as generate
|
@@ -64,12 +75,15 @@ serialization. See the wiki for more on this.
|
|
64
75
|
|
65
76
|
#### Internals
|
66
77
|
|
67
|
-
There are
|
78
|
+
There are four Ruby sub modules of the JrJackson module
|
79
|
+
|
80
|
+
```JrJackson::Json```, this is the general external facade used by MultiJson.
|
68
81
|
|
69
|
-
```JrJackson::
|
82
|
+
```JrJackson::Raw```, this exists for backward compatibility, do not use this for new code.
|
70
83
|
|
71
|
-
```JrJackson::
|
72
|
-
|
84
|
+
```JrJackson::Ruby```, this is used by the external facade, you should use this directly. It returns Ruby objects e.g. Hash, Array, Symbol, String, Integer, BigDecimal etc.
|
85
|
+
|
86
|
+
```JrJackson::Java```, this is used by the external facade, you should use this directly. It returns Java objects e.g. ArrayList, HashMap, BigDecimal, BigInteger, Long, Float and String, JRuby wraps (mostly) them in a JavaProxy Ruby object.
|
73
87
|
|
74
88
|
***
|
75
89
|
|
@@ -79,34 +93,55 @@ Credit to Chuck Remes for the benchmark and initial
|
|
79
93
|
investigation when the jruby, json gem and the jackson
|
80
94
|
libraries were young.
|
81
95
|
|
82
|
-
I compared Json (java) 1.8, Gson 0.6.1 and jackson 2.
|
96
|
+
I compared Json (java) 1.8.3, Gson 0.6.1 and jackson 2.6.1 on jruby 1.7.22 and Oracle Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27 +jit [linux-amd64]
|
83
97
|
All the benchmarks were run separately. A 727.9KB string of random json data is read from a file and handled 250 times, thereby attempting to balance invocation and parsing benchmarking.
|
84
98
|
|
85
99
|
```
|
86
100
|
generation/serialize
|
87
101
|
|
88
102
|
user system total real
|
89
|
-
|
90
|
-
|
91
|
-
json java generate: 250
|
92
|
-
gson generate: 250
|
93
|
-
jackson generate: 250
|
94
|
-
|
103
|
+
|
104
|
+
|
105
|
+
json java generate: 250 6.780 0.620 7.400 ( 6.599)
|
106
|
+
gson generate: 250 4.480 0.530 5.010 ( 4.688)
|
107
|
+
jackson generate: 250 2.200 0.010 2.210 ( 2.128)
|
108
|
+
|
109
|
+
json mri parse: 250 9.620 0.000 9.620 ( 9.631)
|
110
|
+
oj mri parse: 250 9.190 0.000 9.190 ( 9.199)
|
111
|
+
json mri generate: 250 8.400 0.010 8.410 ( 8.419)
|
112
|
+
oj mri generate: 250 6.980 0.010 6.990 ( 6.999)
|
95
113
|
|
96
114
|
|
97
115
|
parsing/deserialize - after jrjackson parsing profiling
|
98
116
|
|
99
117
|
user system total real
|
100
|
-
json
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
jackson parse
|
106
|
-
jackson parse
|
107
|
-
jackson parse symbol
|
108
|
-
jackson parse
|
109
|
-
jackson parse
|
110
|
-
jackson parse
|
118
|
+
json java parse: 250 9.320 0.580 9.900 ( 9.467)
|
119
|
+
jackson parse string keys: 250 3.600 0.520 4.120 ( 3.823)
|
120
|
+
jackson parse string + bigdecimal: 250 3.390 0.640 4.030 ( 3.721)
|
121
|
+
jackson parse ruby compat: 250 3.700 0.030 3.730 ( 3.516)
|
122
|
+
jackson parse ruby ootb: 250 3.490 0.120 3.610 ( 3.420)
|
123
|
+
jackson parse sj: 250 3.290 0.030 3.320 ( 3.065)
|
124
|
+
jackson parse symbol keys: 250 3.050 0.120 3.170 ( 2.943)
|
125
|
+
jackson parse symbol + bigdecimal: 250 2.770 0.020 2.790 ( 2.669)
|
126
|
+
jackson parse java + bigdecimal: 250 1.880 0.430 2.310 ( 2.239)
|
127
|
+
jackson parse java + bigdecimal direct: 250 1.950 0.440 2.390 ( 2.290)
|
128
|
+
jackson parse java ootb: 250 1.990 0.030 2.020 ( 1.925)
|
129
|
+
jackson parse java sym bd: 250 1.920 0.000 1.920 ( 1.898)
|
130
|
+
```
|
131
|
+
|
132
|
+
I have done IPS style benchmarks too.
|
133
|
+
|
134
|
+
Generation
|
135
|
+
```
|
136
|
+
jrjackson: 74539.4 i/s
|
137
|
+
gson: 58288.3 i/s - 1.28x slower
|
138
|
+
JSON: 54597.2 i/s - 1.37x slower
|
139
|
+
```
|
140
|
+
|
141
|
+
Parsing returning Ruby
|
142
|
+
```
|
143
|
+
symbol keys
|
144
|
+
jrjackson: 95203.9 i/s
|
145
|
+
JSON: 40712.0 i/s - 2.34x slower
|
111
146
|
|
112
147
|
```
|
data/changelog.md
CHANGED
data/lib/jrjackson/build_info.rb
CHANGED
Binary file
|
@@ -208,9 +208,12 @@ public class RubyAnySerializer {
|
|
208
208
|
|
209
209
|
private void serializeKey(IRubyObject key, JsonGenerator jgen, SerializerProvider provider)
|
210
210
|
throws IOException, JsonGenerationException {
|
211
|
-
|
212
|
-
|
213
|
-
|
211
|
+
if(key instanceof RubyString) {
|
212
|
+
jgen.writeFieldName(((RubyString)key).decodeString());
|
213
|
+
} else {
|
214
|
+
// includes RubySymbol and non RubyString objects
|
215
|
+
jgen.writeFieldName(key.toString());
|
216
|
+
}
|
214
217
|
}
|
215
218
|
|
216
219
|
/**
|
data/test/jrjackson_test.rb
CHANGED
@@ -477,6 +477,12 @@ class JrJacksonTest < Test::Unit::TestCase
|
|
477
477
|
assert_equal "{\n \"foo\" : 5,\n \"utf8\" : \"żółć\"\n}", actual
|
478
478
|
end
|
479
479
|
|
480
|
+
def test_can_serialise_non_string_keys
|
481
|
+
object = {5 => "foo"}
|
482
|
+
actual = JrJackson::Json.dump(object)
|
483
|
+
assert_equal "{\"5\":\"foo\"}", actual
|
484
|
+
end
|
485
|
+
|
480
486
|
# -----------------------------
|
481
487
|
|
482
488
|
def assert_bigdecimal_equal(expected, actual)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jrjackson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy Boertje
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|