json 2.7.3 → 2.10.1
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/CHANGES.md +61 -0
- data/LEGAL +0 -52
- data/README.md +61 -57
- data/ext/json/ext/fbuffer/fbuffer.h +123 -64
- data/ext/json/ext/generator/generator.c +795 -474
- data/ext/json/ext/parser/extconf.rb +5 -27
- data/ext/json/ext/parser/parser.c +1164 -1923
- data/json.gemspec +7 -5
- data/lib/json/add/bigdecimal.rb +1 -1
- data/lib/json/add/symbol.rb +7 -2
- data/lib/json/common.rb +341 -77
- data/lib/json/ext/generator/state.rb +2 -31
- data/lib/json/ext.rb +28 -11
- data/lib/json/{pure → truffle_ruby}/generator.rb +264 -154
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +15 -20
- metadata +8 -17
- data/ext/json/ext/generator/generator.h +0 -129
- data/ext/json/ext/parser/parser.h +0 -60
- data/ext/json/ext/parser/parser.rl +0 -997
- data/lib/json/pure/parser.rb +0 -331
- data/lib/json/pure.rb +0 -16
data/lib/json.rb
CHANGED
@@ -378,13 +378,13 @@ require 'json/common'
|
|
378
378
|
# json1 = JSON.generate(ruby)
|
379
379
|
# ruby1 = JSON.parse(json1, create_additions: true)
|
380
380
|
# # Make a nice display.
|
381
|
-
# display =
|
382
|
-
#
|
383
|
-
#
|
384
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
#
|
381
|
+
# display = <<~EOT
|
382
|
+
# Generated JSON:
|
383
|
+
# Without addition: #{json0} (#{json0.class})
|
384
|
+
# With addition: #{json1} (#{json1.class})
|
385
|
+
# Parsed JSON:
|
386
|
+
# Without addition: #{ruby0.inspect} (#{ruby0.class})
|
387
|
+
# With addition: #{ruby1.inspect} (#{ruby1.class})
|
388
388
|
# EOT
|
389
389
|
# puts display
|
390
390
|
#
|
@@ -562,13 +562,13 @@ require 'json/common'
|
|
562
562
|
# json1 = JSON.generate(foo1)
|
563
563
|
# obj1 = JSON.parse(json1, create_additions: true)
|
564
564
|
# # Make a nice display.
|
565
|
-
# display =
|
566
|
-
#
|
567
|
-
#
|
568
|
-
#
|
569
|
-
#
|
570
|
-
#
|
571
|
-
#
|
565
|
+
# display = <<~EOT
|
566
|
+
# Generated JSON:
|
567
|
+
# Without custom addition: #{json0} (#{json0.class})
|
568
|
+
# With custom addition: #{json1} (#{json1.class})
|
569
|
+
# Parsed JSON:
|
570
|
+
# Without custom addition: #{obj0.inspect} (#{obj0.class})
|
571
|
+
# With custom addition: #{obj1.inspect} (#{obj1.class})
|
572
572
|
# EOT
|
573
573
|
# puts display
|
574
574
|
#
|
@@ -583,10 +583,5 @@ require 'json/common'
|
|
583
583
|
#
|
584
584
|
module JSON
|
585
585
|
require 'json/version'
|
586
|
-
|
587
|
-
begin
|
588
|
-
require 'json/ext'
|
589
|
-
rescue LoadError
|
590
|
-
require 'json/pure'
|
591
|
-
end
|
586
|
+
require 'json/ext'
|
592
587
|
end
|
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.
|
4
|
+
version: 2.10.1
|
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: 2025-02-10 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
|
@@ -27,11 +26,8 @@ files:
|
|
27
26
|
- ext/json/ext/fbuffer/fbuffer.h
|
28
27
|
- ext/json/ext/generator/extconf.rb
|
29
28
|
- ext/json/ext/generator/generator.c
|
30
|
-
- ext/json/ext/generator/generator.h
|
31
29
|
- ext/json/ext/parser/extconf.rb
|
32
30
|
- ext/json/ext/parser/parser.c
|
33
|
-
- ext/json/ext/parser/parser.h
|
34
|
-
- ext/json/ext/parser/parser.rl
|
35
31
|
- json.gemspec
|
36
32
|
- lib/json.rb
|
37
33
|
- lib/json/add/bigdecimal.rb
|
@@ -52,21 +48,17 @@ files:
|
|
52
48
|
- lib/json/ext.rb
|
53
49
|
- lib/json/ext/generator/state.rb
|
54
50
|
- lib/json/generic_object.rb
|
55
|
-
- lib/json/
|
56
|
-
- lib/json/pure/generator.rb
|
57
|
-
- lib/json/pure/parser.rb
|
51
|
+
- lib/json/truffle_ruby/generator.rb
|
58
52
|
- lib/json/version.rb
|
59
|
-
homepage: https://
|
53
|
+
homepage: https://github.com/ruby/json
|
60
54
|
licenses:
|
61
55
|
- Ruby
|
62
56
|
metadata:
|
63
57
|
bug_tracker_uri: https://github.com/ruby/json/issues
|
64
58
|
changelog_uri: https://github.com/ruby/json/blob/master/CHANGES.md
|
65
|
-
documentation_uri: https://ruby.
|
66
|
-
homepage_uri: https://
|
59
|
+
documentation_uri: https://docs.ruby-lang.org/en/master/JSON.html
|
60
|
+
homepage_uri: https://github.com/ruby/json
|
67
61
|
source_code_uri: https://github.com/ruby/json
|
68
|
-
wiki_uri: https://github.com/ruby/json/wiki
|
69
|
-
post_install_message:
|
70
62
|
rdoc_options:
|
71
63
|
- "--title"
|
72
64
|
- JSON implementation for Ruby
|
@@ -78,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
70
|
requirements:
|
79
71
|
- - ">="
|
80
72
|
- !ruby/object:Gem::Version
|
81
|
-
version: '2.
|
73
|
+
version: '2.7'
|
82
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
75
|
requirements:
|
84
76
|
- - ">="
|
85
77
|
- !ruby/object:Gem::Version
|
86
78
|
version: '0'
|
87
79
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
89
|
-
signing_key:
|
80
|
+
rubygems_version: 3.6.2
|
90
81
|
specification_version: 4
|
91
82
|
summary: JSON Implementation for Ruby
|
92
83
|
test_files: []
|
@@ -1,129 +0,0 @@
|
|
1
|
-
#ifndef _GENERATOR_H_
|
2
|
-
#define _GENERATOR_H_
|
3
|
-
|
4
|
-
#include <math.h>
|
5
|
-
#include <ctype.h>
|
6
|
-
|
7
|
-
#include "ruby.h"
|
8
|
-
|
9
|
-
/* This is the fallback definition from Ruby 3.4 */
|
10
|
-
#ifndef RBIMPL_STDBOOL_H
|
11
|
-
#if defined(__cplusplus)
|
12
|
-
# if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
|
13
|
-
# include <cstdbool>
|
14
|
-
# endif
|
15
|
-
#elif defined(HAVE_STDBOOL_H)
|
16
|
-
# include <stdbool.h>
|
17
|
-
#elif !defined(HAVE__BOOL)
|
18
|
-
typedef unsigned char _Bool;
|
19
|
-
# define bool _Bool
|
20
|
-
# define true ((_Bool)+1)
|
21
|
-
# define false ((_Bool)+0)
|
22
|
-
# define __bool_true_false_are_defined
|
23
|
-
#endif
|
24
|
-
#endif
|
25
|
-
|
26
|
-
static char *fstrndup(const char *ptr, unsigned long len);
|
27
|
-
|
28
|
-
/* ruby api and some helpers */
|
29
|
-
|
30
|
-
typedef struct JSON_Generator_StateStruct {
|
31
|
-
char *indent;
|
32
|
-
long indent_len;
|
33
|
-
char *space;
|
34
|
-
long space_len;
|
35
|
-
char *space_before;
|
36
|
-
long space_before_len;
|
37
|
-
char *object_nl;
|
38
|
-
long object_nl_len;
|
39
|
-
char *array_nl;
|
40
|
-
long array_nl_len;
|
41
|
-
long max_nesting;
|
42
|
-
char allow_nan;
|
43
|
-
char ascii_only;
|
44
|
-
char script_safe;
|
45
|
-
char strict;
|
46
|
-
long depth;
|
47
|
-
long buffer_initial_length;
|
48
|
-
} JSON_Generator_State;
|
49
|
-
|
50
|
-
#define GET_STATE_TO(self, state) \
|
51
|
-
TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
|
52
|
-
|
53
|
-
#define GET_STATE(self) \
|
54
|
-
JSON_Generator_State *state; \
|
55
|
-
GET_STATE_TO(self, state)
|
56
|
-
|
57
|
-
#define GENERATE_JSON(type) \
|
58
|
-
FBuffer *buffer; \
|
59
|
-
VALUE Vstate; \
|
60
|
-
JSON_Generator_State *state; \
|
61
|
-
\
|
62
|
-
rb_scan_args(argc, argv, "01", &Vstate); \
|
63
|
-
Vstate = cState_from_state_s(cState, Vstate); \
|
64
|
-
TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \
|
65
|
-
buffer = cState_prepare_buffer(Vstate); \
|
66
|
-
generate_json_##type(buffer, Vstate, state, self); \
|
67
|
-
return fbuffer_to_s(buffer)
|
68
|
-
|
69
|
-
static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self);
|
70
|
-
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self);
|
71
|
-
#ifdef RUBY_INTEGER_UNIFICATION
|
72
|
-
static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self);
|
73
|
-
#else
|
74
|
-
static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self);
|
75
|
-
static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self);
|
76
|
-
#endif
|
77
|
-
static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self);
|
78
|
-
static VALUE mString_included_s(VALUE self, VALUE modul);
|
79
|
-
static VALUE mString_to_json(int argc, VALUE *argv, VALUE self);
|
80
|
-
static VALUE mString_to_json_raw_object(VALUE self);
|
81
|
-
static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self);
|
82
|
-
static VALUE mString_Extend_json_create(VALUE self, VALUE o);
|
83
|
-
static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self);
|
84
|
-
static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self);
|
85
|
-
static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);
|
86
|
-
static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);
|
87
|
-
static void State_free(void *state);
|
88
|
-
static VALUE cState_s_allocate(VALUE klass);
|
89
|
-
static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
90
|
-
static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
91
|
-
static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
92
|
-
static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
93
|
-
static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
94
|
-
static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
95
|
-
static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
96
|
-
#ifdef RUBY_INTEGER_UNIFICATION
|
97
|
-
static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
98
|
-
#endif
|
99
|
-
static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
100
|
-
static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
101
|
-
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
102
|
-
static VALUE cState_partial_generate(VALUE self, VALUE obj);
|
103
|
-
static VALUE cState_generate(VALUE self, VALUE obj);
|
104
|
-
static VALUE cState_from_state_s(VALUE self, VALUE opts);
|
105
|
-
static VALUE cState_indent(VALUE self);
|
106
|
-
static VALUE cState_indent_set(VALUE self, VALUE indent);
|
107
|
-
static VALUE cState_space(VALUE self);
|
108
|
-
static VALUE cState_space_set(VALUE self, VALUE space);
|
109
|
-
static VALUE cState_space_before(VALUE self);
|
110
|
-
static VALUE cState_space_before_set(VALUE self, VALUE space_before);
|
111
|
-
static VALUE cState_object_nl(VALUE self);
|
112
|
-
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl);
|
113
|
-
static VALUE cState_array_nl(VALUE self);
|
114
|
-
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl);
|
115
|
-
static VALUE cState_max_nesting(VALUE self);
|
116
|
-
static VALUE cState_max_nesting_set(VALUE self, VALUE depth);
|
117
|
-
static VALUE cState_allow_nan_p(VALUE self);
|
118
|
-
static VALUE cState_ascii_only_p(VALUE self);
|
119
|
-
static VALUE cState_depth(VALUE self);
|
120
|
-
static VALUE cState_depth_set(VALUE self, VALUE depth);
|
121
|
-
static VALUE cState_script_safe(VALUE self);
|
122
|
-
static VALUE cState_script_safe_set(VALUE self, VALUE depth);
|
123
|
-
static VALUE cState_strict(VALUE self);
|
124
|
-
static VALUE cState_strict_set(VALUE self, VALUE strict);
|
125
|
-
static FBuffer *cState_prepare_buffer(VALUE self);
|
126
|
-
|
127
|
-
static const rb_data_type_t JSON_Generator_State_type;
|
128
|
-
|
129
|
-
#endif
|
@@ -1,60 +0,0 @@
|
|
1
|
-
#ifndef _PARSER_H_
|
2
|
-
#define _PARSER_H_
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
#ifndef MAYBE_UNUSED
|
7
|
-
# define MAYBE_UNUSED(x) x
|
8
|
-
#endif
|
9
|
-
|
10
|
-
#define option_given_p(opts, key) (rb_hash_lookup2(opts, key, Qundef) != Qundef)
|
11
|
-
|
12
|
-
typedef struct JSON_ParserStruct {
|
13
|
-
VALUE Vsource;
|
14
|
-
char *source;
|
15
|
-
long len;
|
16
|
-
char *memo;
|
17
|
-
VALUE create_id;
|
18
|
-
int max_nesting;
|
19
|
-
int allow_nan;
|
20
|
-
int parsing_name;
|
21
|
-
int symbolize_names;
|
22
|
-
int freeze;
|
23
|
-
VALUE object_class;
|
24
|
-
VALUE array_class;
|
25
|
-
VALUE decimal_class;
|
26
|
-
int create_additions;
|
27
|
-
VALUE match_string;
|
28
|
-
FBuffer *fbuffer;
|
29
|
-
} JSON_Parser;
|
30
|
-
|
31
|
-
#define GET_PARSER \
|
32
|
-
GET_PARSER_INIT; \
|
33
|
-
if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
|
34
|
-
#define GET_PARSER_INIT \
|
35
|
-
JSON_Parser *json; \
|
36
|
-
TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, json)
|
37
|
-
|
38
|
-
#define MinusInfinity "-Infinity"
|
39
|
-
#define EVIL 0x666
|
40
|
-
|
41
|
-
static uint32_t unescape_unicode(const unsigned char *p);
|
42
|
-
static int convert_UTF32_to_UTF8(char *buf, uint32_t ch);
|
43
|
-
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
44
|
-
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
45
|
-
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
46
|
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
47
|
-
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
48
|
-
static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize);
|
49
|
-
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
50
|
-
static VALUE convert_encoding(VALUE source);
|
51
|
-
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
|
52
|
-
static VALUE cParser_parse(VALUE self);
|
53
|
-
static void JSON_mark(void *json);
|
54
|
-
static void JSON_free(void *json);
|
55
|
-
static VALUE cJSON_parser_s_allocate(VALUE klass);
|
56
|
-
static VALUE cParser_source(VALUE self);
|
57
|
-
|
58
|
-
static const rb_data_type_t JSON_Parser_type;
|
59
|
-
|
60
|
-
#endif
|