From 13720f64653f312bcb4e447bafc573744f7141d5 Mon Sep 17 00:00:00 2001 From: Watson Date: Sun, 6 Nov 2022 22:27:27 +0900 Subject: [PATCH] Add descriptions of the missing options to document (#824) * Add document of `:fast` option in `:bigdecimal_load` This option was introduced at https://github.com/ohler55/oj/commit/80bee006fe1baabd87531ff1095bebeb27826fcd * Add document of `:ruby` option in `:bigdecimal_load` This option was introduced at https://github.com/ohler55/oj/commit/3c1c8964341c805977dbe6cbeb573d48489c726d * Add document of `:slash` option in `:escape_mode` This option was introduced at https://github.com/ohler55/oj/commit/f1e77489e03f0a47bdf296eac29e9b8d9b663d32 * Fix typo --- ext/oj/oj.c | 4 ++-- pages/Options.md | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/oj/oj.c b/ext/oj/oj.c index 211e2472..eb310bfe 100644 --- a/ext/oj/oj.c +++ b/ext/oj/oj.c @@ -243,7 +243,7 @@ struct _options oj_default_options = { *references * - *:auto_define* [_Boolean_|_nil_] automatically define classes if they do not exist * - *:symbol_keys* [_Boolean_|_nil_] use symbols instead of strings for hash keys - * - *:escape_mode* [_:newline_|_:json_|_:xss_safe_|_:ascii_|_unicode_xss_|_nil_] determines the + * - *:escape_mode* [_:newline_|_:json_|_:slash_|_:xss_safe_|_:ascii_|_:unicode_xss_|_nil_] determines the *characters to escape * - *:class_cache* [_Boolean_|_nil_] cache classes for faster parsing (if dynamically modifying *classes or reloading classes then don't use this) @@ -251,7 +251,7 @@ struct _options oj_default_options = { *to use for JSON * - *:time_format* [_:unix_|_:unix_zone_|_:xmlschema_|_:ruby_] time format when dumping * - *:bigdecimal_as_decimal* [_Boolean_|_nil_] dump BigDecimal as a decimal number or as a String - * - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_:fast_] load decimals as BigDecimal instead + * - *:bigdecimal_load* [_:bigdecimal_|_:float_|_:auto_|_:fast_|_:ruby_] load decimals as BigDecimal instead *of as a Float. :auto pick the most precise for the number of digits. :float should be the same as *ruby. :fast may require rounding but is must faster. * - *:compat_bigdecimal* [_true_|_false_] load decimals as BigDecimal instead of as a Float when in diff --git a/pages/Options.md b/pages/Options.md index 906829ff..42ad524a 100644 --- a/pages/Options.md +++ b/pages/Options.md @@ -66,6 +66,10 @@ Determines how to load decimals. - `:auto` the most precise for the number of digits is used. + - `:fast` faster conversion to Float. + + - `:ruby` convert to Float using the Ruby `to_f` conversion. + This can also be set with `:decimal_class` when used as a load or parse option to match the JSON gem. In that case either `Float`, `BigDecimal`, or `nil` can be provided. @@ -154,6 +158,8 @@ Determines the characters to escape when dumping. Only the :ascii and - `:json` follows the JSON specification. This is the default mode. + - `:slash` escapes `/` characters. + - `:xss_safe` escapes HTML and XML characters such as `&` and `<`. - `:ascii` escapes all non-ascii or characters with the hi-bit set.