json 2.7.1 → 2.7.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/README.md +0 -9
- data/ext/json/ext/generator/generator.c +36 -6
- data/lib/json/add/ostruct.rb +5 -2
- data/lib/json/common.rb +2 -1
- data/lib/json/generic_object.rb +6 -2
- data/lib/json/version.rb +1 -1
- metadata +3 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1ae811d90e98bbf8438c5abff24a9eabd5ef9c929115c14d3616a0c23f3a3fa2
         | 
| 4 | 
            +
              data.tar.gz: eaa6afeb5ed814f5272bf54172b98ab217b26f850cb91d6fb081a9551237030c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c4119c5fdb66b553ee50cab0185cdec0ff7b09f102cfec8faa28efe2a6042d1e5cb46ada853afdc47b76707b5b180e0f68fb039e08e329935434716e2419b8e1
         | 
| 7 | 
            +
              data.tar.gz: f7d69e1e729e4b37687358bd6ebf81e8909fe4418bfff5c8a2d676b070d6af979146d0b18c01820d5bd4a7f567a62cbb90d0e164e96d05c0e99d9968657467c0
         | 
    
        data/README.md
    CHANGED
    
    | @@ -140,15 +140,6 @@ JSON JSON(1..10) # => 1..10 | |
| 140 140 | 
             
            To find out how to add JSON support to other or your own classes, read the
         | 
| 141 141 | 
             
            section "More Examples" below.
         | 
| 142 142 |  | 
| 143 | 
            -
            To get the best compatibility to rails' JSON implementation, you can
         | 
| 144 | 
            -
             | 
| 145 | 
            -
            ```ruby
         | 
| 146 | 
            -
            require 'json/add/rails'
         | 
| 147 | 
            -
            ```
         | 
| 148 | 
            -
             | 
| 149 | 
            -
            Both of the additions attempt to require `'json'` (like above) first, if it has
         | 
| 150 | 
            -
            not been required yet.
         | 
| 151 | 
            -
             | 
| 152 143 | 
             
            ## Serializing exceptions
         | 
| 153 144 |  | 
| 154 145 | 
             
            The JSON module doesn't extend `Exception` by default. If you convert an `Exception`
         | 
| @@ -867,7 +867,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg) | |
| 867 867 | 
             
                if (klass == rb_cString) {
         | 
| 868 868 | 
             
                    key_to_s = key;
         | 
| 869 869 | 
             
                } else if (klass == rb_cSymbol) {
         | 
| 870 | 
            -
                    key_to_s =  | 
| 870 | 
            +
                    key_to_s = rb_sym2str(key);
         | 
| 871 871 | 
             
                } else {
         | 
| 872 872 | 
             
                    key_to_s = rb_funcall(key, i_to_s, 0);
         | 
| 873 873 | 
             
                }
         | 
| @@ -892,7 +892,6 @@ static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_S | |
| 892 892 | 
             
                struct hash_foreach_arg arg;
         | 
| 893 893 |  | 
| 894 894 | 
             
                if (max_nesting != 0 && depth > max_nesting) {
         | 
| 895 | 
            -
                    fbuffer_free(buffer);
         | 
| 896 895 | 
             
                    rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
         | 
| 897 896 | 
             
                }
         | 
| 898 897 | 
             
                fbuffer_append_char(buffer, '{');
         | 
| @@ -927,7 +926,6 @@ static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_St | |
| 927 926 | 
             
                long depth = ++state->depth;
         | 
| 928 927 | 
             
                int i, j;
         | 
| 929 928 | 
             
                if (max_nesting != 0 && depth > max_nesting) {
         | 
| 930 | 
            -
                    fbuffer_free(buffer);
         | 
| 931 929 | 
             
                    rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
         | 
| 932 930 | 
             
                }
         | 
| 933 931 | 
             
                fbuffer_append_char(buffer, '[');
         | 
| @@ -1020,10 +1018,8 @@ static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_St | |
| 1020 1018 | 
             
                VALUE tmp = rb_funcall(obj, i_to_s, 0);
         | 
| 1021 1019 | 
             
                if (!allow_nan) {
         | 
| 1022 1020 | 
             
                    if (isinf(value)) {
         | 
| 1023 | 
            -
                        fbuffer_free(buffer);
         | 
| 1024 1021 | 
             
                        rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp));
         | 
| 1025 1022 | 
             
                    } else if (isnan(value)) {
         | 
| 1026 | 
            -
                        fbuffer_free(buffer);
         | 
| 1027 1023 | 
             
                        rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp));
         | 
| 1028 1024 | 
             
                    }
         | 
| 1029 1025 | 
             
                }
         | 
| @@ -1096,11 +1092,45 @@ static FBuffer *cState_prepare_buffer(VALUE self) | |
| 1096 1092 | 
             
                return buffer;
         | 
| 1097 1093 | 
             
            }
         | 
| 1098 1094 |  | 
| 1095 | 
            +
            struct generate_json_data {
         | 
| 1096 | 
            +
                FBuffer *buffer;
         | 
| 1097 | 
            +
                VALUE vstate;
         | 
| 1098 | 
            +
                JSON_Generator_State *state;
         | 
| 1099 | 
            +
                VALUE obj;
         | 
| 1100 | 
            +
            };
         | 
| 1101 | 
            +
             | 
| 1102 | 
            +
            static VALUE generate_json_try(VALUE d)
         | 
| 1103 | 
            +
            {
         | 
| 1104 | 
            +
                struct generate_json_data *data = (struct generate_json_data *)d;
         | 
| 1105 | 
            +
             | 
| 1106 | 
            +
                generate_json(data->buffer, data->vstate, data->state, data->obj);
         | 
| 1107 | 
            +
             | 
| 1108 | 
            +
                return Qnil;
         | 
| 1109 | 
            +
            }
         | 
| 1110 | 
            +
             | 
| 1111 | 
            +
            static VALUE generate_json_rescue(VALUE d, VALUE exc)
         | 
| 1112 | 
            +
            {
         | 
| 1113 | 
            +
                struct generate_json_data *data = (struct generate_json_data *)d;
         | 
| 1114 | 
            +
                fbuffer_free(data->buffer);
         | 
| 1115 | 
            +
             | 
| 1116 | 
            +
                rb_exc_raise(exc);
         | 
| 1117 | 
            +
             | 
| 1118 | 
            +
                return Qundef;
         | 
| 1119 | 
            +
            }
         | 
| 1120 | 
            +
             | 
| 1099 1121 | 
             
            static VALUE cState_partial_generate(VALUE self, VALUE obj)
         | 
| 1100 1122 | 
             
            {
         | 
| 1101 1123 | 
             
                FBuffer *buffer = cState_prepare_buffer(self);
         | 
| 1102 1124 | 
             
                GET_STATE(self);
         | 
| 1103 | 
            -
             | 
| 1125 | 
            +
             | 
| 1126 | 
            +
                struct generate_json_data data = {
         | 
| 1127 | 
            +
                    .buffer = buffer,
         | 
| 1128 | 
            +
                    .vstate = self,
         | 
| 1129 | 
            +
                    .state = state,
         | 
| 1130 | 
            +
                    .obj = obj
         | 
| 1131 | 
            +
                };
         | 
| 1132 | 
            +
                rb_rescue(generate_json_try, (VALUE)&data, generate_json_rescue, (VALUE)&data);
         | 
| 1133 | 
            +
             | 
| 1104 1134 | 
             
                return fbuffer_to_s(buffer);
         | 
| 1105 1135 | 
             
            }
         | 
| 1106 1136 |  | 
    
        data/lib/json/add/ostruct.rb
    CHANGED
    
    | @@ -2,7 +2,10 @@ | |
| 2 2 | 
             
            unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
         | 
| 3 3 | 
             
              require 'json'
         | 
| 4 4 | 
             
            end
         | 
| 5 | 
            -
             | 
| 5 | 
            +
            begin
         | 
| 6 | 
            +
              require 'ostruct'
         | 
| 7 | 
            +
            rescue LoadError
         | 
| 8 | 
            +
            end
         | 
| 6 9 |  | 
| 7 10 | 
             
            class OpenStruct
         | 
| 8 11 |  | 
| @@ -48,4 +51,4 @@ class OpenStruct | |
| 48 51 | 
             
              def to_json(*args)
         | 
| 49 52 | 
             
                as_json.to_json(*args)
         | 
| 50 53 | 
             
              end
         | 
| 51 | 
            -
            end
         | 
| 54 | 
            +
            end if defined?(::OpenStruct)
         | 
    
        data/lib/json/common.rb
    CHANGED
    
    
    
        data/lib/json/generic_object.rb
    CHANGED
    
    | @@ -1,5 +1,9 @@ | |
| 1 1 | 
             
            #frozen_string_literal: false
         | 
| 2 | 
            -
             | 
| 2 | 
            +
            begin
         | 
| 3 | 
            +
              require 'ostruct'
         | 
| 4 | 
            +
            rescue LoadError
         | 
| 5 | 
            +
              warn "JSON::GenericObject requires 'ostruct'. Please install it with `gem install ostruct`."
         | 
| 6 | 
            +
            end
         | 
| 3 7 |  | 
| 4 8 | 
             
            module JSON
         | 
| 5 9 | 
             
              class GenericObject < OpenStruct
         | 
| @@ -67,5 +71,5 @@ module JSON | |
| 67 71 | 
             
                def to_json(*a)
         | 
| 68 72 | 
             
                  as_json.to_json(*a)
         | 
| 69 73 | 
             
                end
         | 
| 70 | 
            -
              end
         | 
| 74 | 
            +
              end if defined?(::OpenStruct)
         | 
| 71 75 | 
             
            end
         | 
    
        data/lib/json/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: json
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.7. | 
| 4 | 
            +
              version: 2.7.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Florian Frank
         | 
| 8 | 
            -
            autorequire:
         | 
| 9 8 | 
             
            bindir: bin
         | 
| 10 9 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 10 | 
            +
            date: 2024-04-04 00:00:00.000000000 Z
         | 
| 12 11 | 
             
            dependencies: []
         | 
| 13 12 | 
             
            description: This is a JSON implementation as a Ruby extension in C.
         | 
| 14 13 | 
             
            email: flori@ping.de
         | 
| @@ -67,7 +66,6 @@ metadata: | |
| 67 66 | 
             
              homepage_uri: https://flori.github.io/json
         | 
| 68 67 | 
             
              source_code_uri: https://github.com/flori/json
         | 
| 69 68 | 
             
              wiki_uri: https://github.com/flori/json/wiki
         | 
| 70 | 
            -
            post_install_message:
         | 
| 71 69 | 
             
            rdoc_options:
         | 
| 72 70 | 
             
            - "--title"
         | 
| 73 71 | 
             
            - JSON implementation for Ruby
         | 
| @@ -86,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 86 84 | 
             
                - !ruby/object:Gem::Version
         | 
| 87 85 | 
             
                  version: '0'
         | 
| 88 86 | 
             
            requirements: []
         | 
| 89 | 
            -
            rubygems_version: 3. | 
| 90 | 
            -
            signing_key:
         | 
| 87 | 
            +
            rubygems_version: 3.6.0.dev
         | 
| 91 88 | 
             
            specification_version: 4
         | 
| 92 89 | 
             
            summary: JSON Implementation for Ruby
         | 
| 93 90 | 
             
            test_files: []
         |