json_kit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json_kit/helper.rb +18 -4
- data/lib/json_kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 124a907f6ecc526f395bdffdd4886b288e4e0de3
|
4
|
+
data.tar.gz: 397d84b0cb92cfcd0ac0218674ea83f5978a3b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af2fa1a9d918ab25793e21bad803e33ab2e435cea7e6574ff88d104b15fb0c167bb11c5f543d0b62fb7e3cf739c762ac1c0e14a87c26f0e9d0fdceb7078a9a93
|
7
|
+
data.tar.gz: 7d62cb449737ce8c13f957ebbbef4483677d00c35f79a919c170577d628f22538a39a8c09c03c1b85d277ef8f4a577ddebccf21abd435c69569794e4bd1a35f6
|
data/lib/json_kit/helper.rb
CHANGED
@@ -18,12 +18,26 @@ module JsonKit
|
|
18
18
|
|
19
19
|
def from_json(json, klass = nil, transforms = [])
|
20
20
|
|
21
|
-
|
21
|
+
obj = JSON.parse(json)
|
22
22
|
|
23
|
-
if
|
24
|
-
return
|
23
|
+
if [String, Fixnum, Numeric, Date, DateTime, Time, Integer].include?(obj.class)
|
24
|
+
return json
|
25
|
+
end
|
26
|
+
|
27
|
+
if obj.is_a?(Array)
|
28
|
+
return obj.map do |i|
|
29
|
+
if klass != nil
|
30
|
+
@hash_helper.from_hash(i, klass, transforms)
|
31
|
+
else
|
32
|
+
@hash_helper.symbolize(i)
|
33
|
+
end
|
34
|
+
end
|
25
35
|
else
|
26
|
-
|
36
|
+
if klass != nil
|
37
|
+
return @hash_helper.from_hash(obj, klass, transforms)
|
38
|
+
else
|
39
|
+
return @hash_helper.symbolize(obj)
|
40
|
+
end
|
27
41
|
end
|
28
42
|
|
29
43
|
end
|
data/lib/json_kit/version.rb
CHANGED