oj 3.13.22 → 3.13.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/oj/oj.c +2 -2
- data/ext/oj/parser.c +6 -2
- data/lib/oj/version.rb +1 -1
- data/pages/Options.md +6 -0
- metadata +2 -3
- data/ext/oj/introspect.c +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d2f8a01b7a59da7cd25ed3551065dddd9e31e5184989804d172c2e39cc769d6
|
4
|
+
data.tar.gz: 7211a96856ec44173fa9dcc7245e3cb2f6b7c2e22a746ef35f168126873f4c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee3ad5cac6cac48bcf7fdf682e69770dfee08b502735cc75b84ae1635196fdcdaf2fde021e32e6d897bdc6935e111882ddc48fa5a274fe0d98ad45c2fdf68917
|
7
|
+
data.tar.gz: 3e05212fa84a2bf05954ec870ac27da7c845335b411507aa0bf5e45497403cccf4c40990f0ee8cee6d21f19163f33116bb240836795482737eaa744bc5ff6d94
|
data/CHANGELOG.md
CHANGED
data/ext/oj/oj.c
CHANGED
@@ -243,7 +243,7 @@ struct _options oj_default_options = {
|
|
243
243
|
*references
|
244
244
|
* - *:auto_define* [_Boolean_|_nil_] automatically define classes if they do not exist
|
245
245
|
* - *:symbol_keys* [_Boolean_|_nil_] use symbols instead of strings for hash keys
|
246
|
-
* - *:escape_mode* [_:newline_|_:json_|_:xss_safe_|_:ascii_|
|
246
|
+
* - *:escape_mode* [_:newline_|_:json_|_:slash_|_:xss_safe_|_:ascii_|_:unicode_xss_|_nil_] determines the
|
247
247
|
*characters to escape
|
248
248
|
* - *:class_cache* [_Boolean_|_nil_] cache classes for faster parsing (if dynamically modifying
|
249
249
|
*classes or reloading classes then don't use this)
|
@@ -251,7 +251,7 @@ struct _options oj_default_options = {
|
|
251
251
|
*to use for JSON
|
252
252
|
* - *:time_format* [_:unix_|_:unix_zone_|_:xmlschema_|_:ruby_] time format when dumping
|
253
253
|
* - *:bigdecimal_as_decimal* [_Boolean_|_nil_] dump BigDecimal as a decimal number or as a String
|
254
|
-
* - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_:fast_] load decimals as BigDecimal instead
|
254
|
+
* - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_:fast_|_:ruby_] load decimals as BigDecimal instead
|
255
255
|
*of as a Float. :auto pick the most precise for the number of digits. :float should be the same as
|
256
256
|
*ruby. :fast may require rounding but is must faster.
|
257
257
|
* - *:compat_bigdecimal* [_true_|_false_] load decimals as BigDecimal instead of as a Float when in
|
data/ext/oj/parser.c
CHANGED
@@ -1145,7 +1145,9 @@ static void parser_free(void *ptr) {
|
|
1145
1145
|
p = (ojParser)ptr;
|
1146
1146
|
buf_cleanup(&p->key);
|
1147
1147
|
buf_cleanup(&p->buf);
|
1148
|
-
p->free
|
1148
|
+
if (NULL != p->free) {
|
1149
|
+
p->free(p);
|
1150
|
+
}
|
1149
1151
|
xfree(ptr);
|
1150
1152
|
}
|
1151
1153
|
|
@@ -1156,7 +1158,9 @@ static void parser_mark(void *ptr) {
|
|
1156
1158
|
if (0 != p->reader) {
|
1157
1159
|
rb_gc_mark(p->reader);
|
1158
1160
|
}
|
1159
|
-
p->mark
|
1161
|
+
if (NULL != p->mark) {
|
1162
|
+
p->mark(p);
|
1163
|
+
}
|
1160
1164
|
}
|
1161
1165
|
}
|
1162
1166
|
|
data/lib/oj/version.rb
CHANGED
data/pages/Options.md
CHANGED
@@ -66,6 +66,10 @@ Determines how to load decimals.
|
|
66
66
|
|
67
67
|
- `:auto` the most precise for the number of digits is used.
|
68
68
|
|
69
|
+
- `:fast` faster conversion to Float.
|
70
|
+
|
71
|
+
- `:ruby` convert to Float using the Ruby `to_f` conversion.
|
72
|
+
|
69
73
|
This can also be set with `:decimal_class` when used as a load or
|
70
74
|
parse option to match the JSON gem. In that case either `Float`,
|
71
75
|
`BigDecimal`, or `nil` can be provided.
|
@@ -154,6 +158,8 @@ Determines the characters to escape when dumping. Only the :ascii and
|
|
154
158
|
|
155
159
|
- `:json` follows the JSON specification. This is the default mode.
|
156
160
|
|
161
|
+
- `:slash` escapes `/` characters.
|
162
|
+
|
157
163
|
- `:xss_safe` escapes HTML and XML characters such as `&` and `<`.
|
158
164
|
|
159
165
|
- `:ascii` escapes all non-ascii or characters with the hi-bit set.
|
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.13.
|
4
|
+
version: 3.13.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -110,7 +110,6 @@ files:
|
|
110
110
|
- ext/oj/fast.c
|
111
111
|
- ext/oj/intern.c
|
112
112
|
- ext/oj/intern.h
|
113
|
-
- ext/oj/introspect.c
|
114
113
|
- ext/oj/mimic_json.c
|
115
114
|
- ext/oj/object.c
|
116
115
|
- ext/oj/odd.c
|
data/ext/oj/introspect.c
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "cache.h"
|
3
|
-
#include "oj.h"
|
4
|
-
#include "parser.h"
|
5
|
-
#include "usual.h"
|
6
|
-
|
7
|
-
#define BYTE_OFFSETS_STACK_INC_SIZE 256
|
8
|
-
|
9
|
-
VALUE mod = Qnil;
|
10
|
-
|
11
|
-
typedef struct _introspect {
|
12
|
-
struct _usual usual;
|
13
|
-
void (*start)(struct _ojParser *p);
|
14
|
-
void (*free)(struct _ojParser *p);
|
15
|
-
void (*mark)(struct _ojParser *p);
|
16
|
-
void (*open_object)(struct _ojParser *p);
|
17
|
-
void (*close_object)(struct _ojParser *p);
|
18
|
-
|
19
|
-
int len;
|
20
|
-
int cur;
|
21
|
-
long *stack;
|
22
|
-
|
23
|
-
} * Introspect;
|
24
|
-
|
25
|
-
static void dfree(ojParser p) {
|
26
|
-
Introspect d = (Introspect)p->ctx;
|
27
|
-
|
28
|
-
xfree(d->stack);
|
29
|
-
// As with the mark() function, this function should still work.
|
30
|
-
d->free(p);
|
31
|
-
}
|
32
|
-
|
33
|
-
static void start(ojParser p) {
|
34
|
-
Introspect d = (Introspect)p->ctx;
|
35
|
-
|
36
|
-
d->start(p);
|
37
|
-
|
38
|
-
d->stack = ALLOC_N(long, BYTE_OFFSETS_STACK_INC_SIZE);
|
39
|
-
d->len = BYTE_OFFSETS_STACK_INC_SIZE;
|
40
|
-
d->cur = 0;
|
41
|
-
}
|
42
|
-
|
43
|
-
static void open_object(ojParser p) {
|
44
|
-
Introspect d = (Introspect)p->ctx;
|
45
|
-
|
46
|
-
d->open_object(p);
|
47
|
-
|
48
|
-
// TBD add offset
|
49
|
-
}
|
50
|
-
|
51
|
-
static void close_object(ojParser p) {
|
52
|
-
Introspect d = (Introspect)p->ctx;
|
53
|
-
|
54
|
-
d->close_object(p);
|
55
|
-
|
56
|
-
// TBD set offset on hash
|
57
|
-
}
|
58
|
-
|
59
|
-
static VALUE new_parser(VALUE self, VALUE ropts) {
|
60
|
-
volatile VALUE pv = oj_parser_new();
|
61
|
-
ojParser p = (ojParser)DATA_PTR(pv);
|
62
|
-
Introspect d = ALLOC(struct _introspect);
|
63
|
-
|
64
|
-
oj_init_usual(p, &d->usual);
|
65
|
-
|
66
|
-
// Set the options before switching to the Introspect delegate.
|
67
|
-
p->ctx = (void *)d;
|
68
|
-
|
69
|
-
d->free = p->free;
|
70
|
-
p->free = dfree;
|
71
|
-
|
72
|
-
d->start = p->start;
|
73
|
-
p->start = start;
|
74
|
-
|
75
|
-
// We are cheating with the mark, free, and options functions. Since
|
76
|
-
// struct _usual is the first member of struct _introspect the cast to
|
77
|
-
// Usual in the usual.c mark() function should still work just fine.
|
78
|
-
|
79
|
-
d->open_object = p->funcs[TOP_FUN].open_object;
|
80
|
-
p->funcs[TOP_FUN].open_object = open_object;
|
81
|
-
|
82
|
-
d->close_object = p->funcs[TOP_FUN].close_object;
|
83
|
-
p->funcs[TOP_FUN].close_object = close_object;
|
84
|
-
|
85
|
-
Check_Type(ropts, T_HASH);
|
86
|
-
oj_parser_set_option(p, ropts);
|
87
|
-
|
88
|
-
return pv;
|
89
|
-
}
|
90
|
-
|
91
|
-
void Init_introspect(void) {
|
92
|
-
mod = rb_define_module("Introspect");
|
93
|
-
rb_gc_register_address(&mod);
|
94
|
-
|
95
|
-
rb_define_module_function(mod, "parser", new_parser, 1);
|
96
|
-
}
|