json_pure 2.7.5 → 2.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/json/pure/generator.rb +26 -7
- data/lib/json/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc10fe68c32c66130244c95986e80f41d17b72ed2d8311fde09c1d82dd8fa154
|
4
|
+
data.tar.gz: 3a9cd865c6b542d9ae199bac464d96d4f0116aee65eb35f7b4acfa1ab97a4f83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ba58d3641b73445fc3b07ba70197b05efd2e319410530c946c8b3733c7ff2b5b3c8db61e482d3c3c52930d544d7637ee442a53670796b7cb7b5dbb9ecea0c0
|
7
|
+
data.tar.gz: 2f35def657dcae3cbbe4593f25513c4340bfbbc1b2ec7b7accec7914007893abf333e2aed047a92cdd24f13d85d03622518f07bad8cbf61caef17c0211235239
|
data/CHANGES.md
CHANGED
data/lib/json/pure/generator.rb
CHANGED
@@ -301,19 +301,30 @@ module JSON
|
|
301
301
|
|
302
302
|
# Handles @allow_nan, @buffer_initial_length, other ivars must be the default value (see above)
|
303
303
|
private def generate_json(obj, buf)
|
304
|
-
|
305
|
-
|
304
|
+
klass = obj.class
|
305
|
+
if klass == Hash
|
306
306
|
buf << '{'
|
307
307
|
first = true
|
308
308
|
obj.each_pair do |k,v|
|
309
309
|
buf << ',' unless first
|
310
|
-
|
310
|
+
|
311
|
+
key_str = k.to_s
|
312
|
+
if key_str.is_a?(::String)
|
313
|
+
if key_str.class == ::String
|
314
|
+
fast_serialize_string(key_str, buf)
|
315
|
+
else
|
316
|
+
generate_json(key_str, buf)
|
317
|
+
end
|
318
|
+
else
|
319
|
+
raise TypeError, "#{k.class}#to_s returns an instance of #{key_str.class}, expected a String"
|
320
|
+
end
|
321
|
+
|
311
322
|
buf << ':'
|
312
323
|
generate_json(v, buf)
|
313
324
|
first = false
|
314
325
|
end
|
315
326
|
buf << '}'
|
316
|
-
|
327
|
+
elsif klass == Array
|
317
328
|
buf << '['
|
318
329
|
first = true
|
319
330
|
obj.each do |e|
|
@@ -322,9 +333,9 @@ module JSON
|
|
322
333
|
first = false
|
323
334
|
end
|
324
335
|
buf << ']'
|
325
|
-
|
336
|
+
elsif klass == String
|
326
337
|
fast_serialize_string(obj, buf)
|
327
|
-
|
338
|
+
elsif klass == Integer
|
328
339
|
buf << obj.to_s
|
329
340
|
else
|
330
341
|
# Note: Float is handled this way since Float#to_s is slow anyway
|
@@ -414,7 +425,15 @@ module JSON
|
|
414
425
|
each { |key, value|
|
415
426
|
result << delim unless first
|
416
427
|
result << state.indent * depth if indent
|
417
|
-
|
428
|
+
|
429
|
+
key_str = key.to_s
|
430
|
+
key_json = if key_str.is_a?(::String)
|
431
|
+
key_str = key_str.to_json(state)
|
432
|
+
else
|
433
|
+
raise TypeError, "#{key.class}#to_s returns an instance of #{key_str.class}, expected a String"
|
434
|
+
end
|
435
|
+
|
436
|
+
result = +"#{result}#{key_json}#{state.space_before}:#{state.space}"
|
418
437
|
if state.strict? && !(false == value || true == value || nil == value || String === value || Array === value || Hash === value || Integer === value || Float === value)
|
419
438
|
raise GeneratorError, "#{value.class} not allowed in JSON"
|
420
439
|
elsif value.respond_to?(:to_json)
|
data/lib/json/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_pure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a JSON implementation in pure Ruby.
|
14
14
|
email: flori@ping.de
|