oj 3.12.1 → 3.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/oj/dump.c +39 -42
- data/ext/oj/dump_strict.c +1 -1
- data/ext/oj/object.c +4 -4
- data/lib/oj/version.rb +1 -1
- data/pages/Options.md +7 -1
- data/test/foo.rb +2 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89a87064f6668864cec4ab0c43892b4950c8ef7a9f7ea3da22f459af5bcd0083
|
4
|
+
data.tar.gz: bc078e8b28d710a2194e2943343db687ec15d35d2556efff2f9e46936f3bb0b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95cb66c13e871bf85a351348b0c458c53fe2cd4057886396a62b763386fafe5d99c97143151808eb70dd526b8f13740cd43e266805c6b3454eac1be6940897db
|
7
|
+
data.tar.gz: '09e24c7ec1daf2c10850b071eb4060aed265db662a92a78439eee1746b22437396f3358f82d982e040874c0916af3c38def244e03416e4971c2c5649823ff7c2'
|
data/ext/oj/dump.c
CHANGED
@@ -535,59 +535,57 @@ void oj_dump_xml_time(VALUE obj, Out out) {
|
|
535
535
|
}
|
536
536
|
if ((0 == nsec && !out->opts->sec_prec_set) || 0 == out->opts->sec_prec) {
|
537
537
|
if (0 == tzsecs && rb_funcall2(obj, oj_utcq_id, 0, 0)) {
|
538
|
-
sprintf(buf,
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
oj_dump_cstr(buf,
|
538
|
+
int len = sprintf(buf,
|
539
|
+
"%04d-%02d-%02dT%02d:%02d:%02dZ",
|
540
|
+
ti.year,
|
541
|
+
ti.mon,
|
542
|
+
ti.day,
|
543
|
+
ti.hour,
|
544
|
+
ti.min,
|
545
|
+
ti.sec);
|
546
|
+
oj_dump_cstr(buf, len, 0, 0, out);
|
547
547
|
} else {
|
548
|
-
sprintf(buf,
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
oj_dump_cstr(buf,
|
548
|
+
int len = sprintf(buf,
|
549
|
+
"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
|
550
|
+
ti.year,
|
551
|
+
ti.mon,
|
552
|
+
ti.day,
|
553
|
+
ti.hour,
|
554
|
+
ti.min,
|
555
|
+
ti.sec,
|
556
|
+
tzsign,
|
557
|
+
tzhour,
|
558
|
+
tzmin);
|
559
|
+
oj_dump_cstr(buf, len, 0, 0, out);
|
560
560
|
}
|
561
561
|
} else if (0 == tzsecs && rb_funcall2(obj, oj_utcq_id, 0, 0)) {
|
562
562
|
char format[64] = "%04d-%02d-%02dT%02d:%02d:%02d.%09ldZ";
|
563
|
-
int len
|
563
|
+
int len;
|
564
564
|
|
565
565
|
if (9 > out->opts->sec_prec) {
|
566
566
|
format[32] = '0' + out->opts->sec_prec;
|
567
|
-
len -= 9 - out->opts->sec_prec;
|
568
567
|
}
|
569
|
-
sprintf(buf, format, ti.year, ti.mon, ti.day, ti.hour, ti.min, ti.sec, (long)nsec);
|
568
|
+
len = sprintf(buf, format, ti.year, ti.mon, ti.day, ti.hour, ti.min, ti.sec, (long)nsec);
|
570
569
|
oj_dump_cstr(buf, len, 0, 0, out);
|
571
570
|
} else {
|
572
571
|
char format[64] = "%04d-%02d-%02dT%02d:%02d:%02d.%09ld%c%02d:%02d";
|
573
|
-
int len
|
572
|
+
int len;
|
574
573
|
|
575
574
|
if (9 > out->opts->sec_prec) {
|
576
575
|
format[32] = '0' + out->opts->sec_prec;
|
577
|
-
len -= 9 - out->opts->sec_prec;
|
578
576
|
}
|
579
|
-
sprintf(buf,
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
577
|
+
len = sprintf(buf,
|
578
|
+
format,
|
579
|
+
ti.year,
|
580
|
+
ti.mon,
|
581
|
+
ti.day,
|
582
|
+
ti.hour,
|
583
|
+
ti.min,
|
584
|
+
ti.sec,
|
585
|
+
(long)nsec,
|
586
|
+
tzsign,
|
587
|
+
tzhour,
|
588
|
+
tzmin);
|
591
589
|
oj_dump_cstr(buf, len, 0, 0, out);
|
592
590
|
}
|
593
591
|
}
|
@@ -827,9 +825,8 @@ void oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out ou
|
|
827
825
|
if (is_sym) {
|
828
826
|
*out->cur++ = ':';
|
829
827
|
}
|
830
|
-
|
831
|
-
|
832
|
-
}
|
828
|
+
memcpy(out->cur, str, cnt);
|
829
|
+
out->cur += cnt;
|
833
830
|
*out->cur++ = '"';
|
834
831
|
} else {
|
835
832
|
const char *end = str + cnt;
|
@@ -1206,7 +1203,7 @@ void oj_dump_float(VALUE obj, int depth, Out out, bool as_ok) {
|
|
1206
1203
|
if ((int)sizeof(buf) <= cnt) {
|
1207
1204
|
cnt = sizeof(buf) - 1;
|
1208
1205
|
}
|
1209
|
-
|
1206
|
+
memcpy(buf, rb_string_value_ptr((VALUE *)&rstr), cnt);
|
1210
1207
|
buf[cnt] = '\0';
|
1211
1208
|
} else {
|
1212
1209
|
cnt = oj_dump_float_printf(buf, sizeof(buf), obj, d, out->opts->float_fmt);
|
data/ext/oj/dump_strict.c
CHANGED
@@ -98,7 +98,7 @@ static void dump_float(VALUE obj, int depth, Out out, bool as_ok) {
|
|
98
98
|
if ((int)sizeof(buf) <= cnt) {
|
99
99
|
cnt = sizeof(buf) - 1;
|
100
100
|
}
|
101
|
-
|
101
|
+
memcpy(buf, rb_string_value_ptr((VALUE *)&rstr), cnt);
|
102
102
|
buf[cnt] = '\0';
|
103
103
|
} else {
|
104
104
|
cnt = oj_dump_float_printf(buf, sizeof(buf), obj, d, out->opts->float_fmt);
|
data/ext/oj/object.c
CHANGED
@@ -433,22 +433,22 @@ void oj_set_obj_ivar(Val parent, Val kval, VALUE value) {
|
|
433
433
|
char *buf = ALLOC_N(char, klen + 2);
|
434
434
|
|
435
435
|
if ('~' == *key) {
|
436
|
-
|
436
|
+
memcpy(buf, key + 1, klen - 1);
|
437
437
|
buf[klen - 1] = '\0';
|
438
438
|
} else {
|
439
439
|
*buf = '@';
|
440
|
-
|
440
|
+
memcpy(buf + 1, key, klen);
|
441
441
|
buf[klen + 1] = '\0';
|
442
442
|
}
|
443
443
|
var_id = rb_intern(buf);
|
444
444
|
xfree(buf);
|
445
445
|
} else {
|
446
446
|
if ('~' == *key) {
|
447
|
-
|
447
|
+
memcpy(attr, key + 1, klen - 1);
|
448
448
|
attr[klen - 1] = '\0';
|
449
449
|
} else {
|
450
450
|
*attr = '@';
|
451
|
-
|
451
|
+
memcpy(attr + 1, key, klen);
|
452
452
|
attr[klen + 1] = '\0';
|
453
453
|
}
|
454
454
|
var_id = rb_intern(attr);
|
data/lib/oj/version.rb
CHANGED
data/pages/Options.md
CHANGED
@@ -251,7 +251,13 @@ compatibility. Using just indent as an integer gives better performance.
|
|
251
251
|
|
252
252
|
### :symbol_keys [Boolean]
|
253
253
|
|
254
|
-
Use symbols instead of strings for hash keys.
|
254
|
+
Use symbols instead of strings for hash keys.
|
255
|
+
|
256
|
+
### :symbolize_names [Boolean]
|
257
|
+
|
258
|
+
Like :symbol_keys has keys are made into symbols but only when
|
259
|
+
mimicing the JSON gem and then only as the JSON gem honors it so
|
260
|
+
JSON.parse honors the option but JSON.load does not.
|
255
261
|
|
256
262
|
### :trace
|
257
263
|
|
data/test/foo.rb
CHANGED
@@ -8,13 +8,6 @@ end
|
|
8
8
|
|
9
9
|
require 'oj'
|
10
10
|
|
11
|
-
|
11
|
+
p = Oj::Parser.new(:debug)
|
12
12
|
|
13
|
-
[
|
14
|
-
GC.start
|
15
|
-
t = Time.now
|
16
|
-
Oj.load_file('pt_lemma_lookup.json', mode: mode)
|
17
|
-
puts "#{mode}: #{Time.now - t}"
|
18
|
-
}
|
19
|
-
|
20
|
-
# check saj and scp
|
13
|
+
p.parse("[true, false]")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.12.
|
4
|
+
version: 3.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
- !ruby/object:Gem::Version
|
286
286
|
version: '0'
|
287
287
|
requirements: []
|
288
|
-
rubygems_version: 3.2.
|
288
|
+
rubygems_version: 3.2.22
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: A fast JSON parser and serializer.
|