jsoncons 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/ext/jsoncons/extconf.rb +43 -0
  3. data/ext/jsoncons/jsoncons.cpp +161 -0
  4. data/ext/jsoncons/jsoncons.h +10 -0
  5. data/jsoncons.gemspec +44 -0
  6. data/lib/jsoncons/jsoncons/examples/input/address-book.json +13 -0
  7. data/lib/jsoncons/jsoncons/examples/input/books.json +28 -0
  8. data/lib/jsoncons/jsoncons/examples/input/countries.json +7 -0
  9. data/lib/jsoncons/jsoncons/examples/input/employees.json +30 -0
  10. data/lib/jsoncons/jsoncons/examples/input/jsonschema/name.json +15 -0
  11. data/lib/jsoncons/jsoncons/examples/input/multiple-json-objects.json +3 -0
  12. data/lib/jsoncons/jsoncons/examples/input/sales.csv +6 -0
  13. data/lib/jsoncons/jsoncons/examples/input/store.json +28 -0
  14. data/lib/jsoncons/jsoncons/examples/input/tasks.csv +6 -0
  15. data/lib/jsoncons/jsoncons/include/jsoncons/allocator_holder.hpp +38 -0
  16. data/lib/jsoncons/jsoncons/include/jsoncons/basic_json.hpp +5905 -0
  17. data/lib/jsoncons/jsoncons/include/jsoncons/bigint.hpp +1611 -0
  18. data/lib/jsoncons/jsoncons/include/jsoncons/byte_string.hpp +820 -0
  19. data/lib/jsoncons/jsoncons/include/jsoncons/config/binary_config.hpp +226 -0
  20. data/lib/jsoncons/jsoncons/include/jsoncons/config/compiler_support.hpp +375 -0
  21. data/lib/jsoncons/jsoncons/include/jsoncons/config/jsoncons_config.hpp +309 -0
  22. data/lib/jsoncons/jsoncons/include/jsoncons/config/version.hpp +40 -0
  23. data/lib/jsoncons/jsoncons/include/jsoncons/conv_error.hpp +218 -0
  24. data/lib/jsoncons/jsoncons/include/jsoncons/decode_json.hpp +209 -0
  25. data/lib/jsoncons/jsoncons/include/jsoncons/decode_traits.hpp +651 -0
  26. data/lib/jsoncons/jsoncons/include/jsoncons/detail/endian.hpp +44 -0
  27. data/lib/jsoncons/jsoncons/include/jsoncons/detail/grisu3.hpp +312 -0
  28. data/lib/jsoncons/jsoncons/include/jsoncons/detail/optional.hpp +483 -0
  29. data/lib/jsoncons/jsoncons/include/jsoncons/detail/parse_number.hpp +1133 -0
  30. data/lib/jsoncons/jsoncons/include/jsoncons/detail/span.hpp +188 -0
  31. data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_view.hpp +537 -0
  32. data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_wrapper.hpp +370 -0
  33. data/lib/jsoncons/jsoncons/include/jsoncons/detail/write_number.hpp +567 -0
  34. data/lib/jsoncons/jsoncons/include/jsoncons/encode_json.hpp +315 -0
  35. data/lib/jsoncons/jsoncons/include/jsoncons/encode_traits.hpp +378 -0
  36. data/lib/jsoncons/jsoncons/include/jsoncons/json.hpp +18 -0
  37. data/lib/jsoncons/jsoncons/include/jsoncons/json_array.hpp +324 -0
  38. data/lib/jsoncons/jsoncons/include/jsoncons/json_content_handler.hpp +12 -0
  39. data/lib/jsoncons/jsoncons/include/jsoncons/json_cursor.hpp +448 -0
  40. data/lib/jsoncons/jsoncons/include/jsoncons/json_decoder.hpp +420 -0
  41. data/lib/jsoncons/jsoncons/include/jsoncons/json_encoder.hpp +1587 -0
  42. data/lib/jsoncons/jsoncons/include/jsoncons/json_error.hpp +156 -0
  43. data/lib/jsoncons/jsoncons/include/jsoncons/json_exception.hpp +241 -0
  44. data/lib/jsoncons/jsoncons/include/jsoncons/json_filter.hpp +653 -0
  45. data/lib/jsoncons/jsoncons/include/jsoncons/json_fwd.hpp +23 -0
  46. data/lib/jsoncons/jsoncons/include/jsoncons/json_object.hpp +1772 -0
  47. data/lib/jsoncons/jsoncons/include/jsoncons/json_options.hpp +862 -0
  48. data/lib/jsoncons/jsoncons/include/jsoncons/json_parser.hpp +2900 -0
  49. data/lib/jsoncons/jsoncons/include/jsoncons/json_reader.hpp +731 -0
  50. data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros.hpp +1072 -0
  51. data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros_deprecated.hpp +144 -0
  52. data/lib/jsoncons/jsoncons/include/jsoncons/json_type.hpp +206 -0
  53. data/lib/jsoncons/jsoncons/include/jsoncons/json_type_traits.hpp +1830 -0
  54. data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor.hpp +1560 -0
  55. data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor2.hpp +2079 -0
  56. data/lib/jsoncons/jsoncons/include/jsoncons/pretty_print.hpp +89 -0
  57. data/lib/jsoncons/jsoncons/include/jsoncons/ser_context.hpp +62 -0
  58. data/lib/jsoncons/jsoncons/include/jsoncons/sink.hpp +289 -0
  59. data/lib/jsoncons/jsoncons/include/jsoncons/source.hpp +777 -0
  60. data/lib/jsoncons/jsoncons/include/jsoncons/source_adaptor.hpp +148 -0
  61. data/lib/jsoncons/jsoncons/include/jsoncons/staj2_cursor.hpp +1189 -0
  62. data/lib/jsoncons/jsoncons/include/jsoncons/staj_cursor.hpp +1254 -0
  63. data/lib/jsoncons/jsoncons/include/jsoncons/staj_iterator.hpp +449 -0
  64. data/lib/jsoncons/jsoncons/include/jsoncons/tag_type.hpp +245 -0
  65. data/lib/jsoncons/jsoncons/include/jsoncons/text_source_adaptor.hpp +144 -0
  66. data/lib/jsoncons/jsoncons/include/jsoncons/traits_extension.hpp +884 -0
  67. data/lib/jsoncons/jsoncons/include/jsoncons/typed_array_view.hpp +250 -0
  68. data/lib/jsoncons/jsoncons/include/jsoncons/unicode_traits.hpp +1330 -0
  69. data/lib/jsoncons/jsoncons/include/jsoncons/uri.hpp +635 -0
  70. data/lib/jsoncons/jsoncons/include/jsoncons/value_converter.hpp +340 -0
  71. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson.hpp +23 -0
  72. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_cursor.hpp +320 -0
  73. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_decimal128.hpp +865 -0
  74. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_encoder.hpp +585 -0
  75. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_error.hpp +103 -0
  76. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_oid.hpp +245 -0
  77. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_options.hpp +75 -0
  78. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_parser.hpp +645 -0
  79. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_reader.hpp +92 -0
  80. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_type.hpp +44 -0
  81. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/decode_bson.hpp +201 -0
  82. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/encode_bson.hpp +144 -0
  83. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor.hpp +26 -0
  84. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor.hpp +351 -0
  85. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor2.hpp +265 -0
  86. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_detail.hpp +93 -0
  87. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_encoder.hpp +1766 -0
  88. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_error.hpp +105 -0
  89. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_options.hpp +113 -0
  90. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_parser.hpp +1942 -0
  91. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_reader.hpp +116 -0
  92. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/decode_cbor.hpp +203 -0
  93. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/encode_cbor.hpp +151 -0
  94. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv.hpp +17 -0
  95. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_cursor.hpp +358 -0
  96. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_encoder.hpp +954 -0
  97. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_error.hpp +85 -0
  98. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_options.hpp +973 -0
  99. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_parser.hpp +2099 -0
  100. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_reader.hpp +348 -0
  101. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_serializer.hpp +12 -0
  102. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/decode_csv.hpp +208 -0
  103. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/encode_csv.hpp +122 -0
  104. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath.hpp +5215 -0
  105. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath_error.hpp +215 -0
  106. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch.hpp +579 -0
  107. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp +121 -0
  108. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/expression.hpp +3329 -0
  109. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/flatten.hpp +432 -0
  110. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_location.hpp +445 -0
  111. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_query.hpp +115 -0
  112. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath.hpp +13 -0
  113. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_error.hpp +240 -0
  114. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp +2612 -0
  115. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp +1322 -0
  116. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer.hpp +1577 -0
  117. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp +119 -0
  118. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/format_validator.hpp +968 -0
  119. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/json_validator.hpp +120 -0
  120. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema.hpp +13 -0
  121. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_error.hpp +105 -0
  122. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_version.hpp +18 -0
  123. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator.hpp +1745 -0
  124. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator_factory.hpp +556 -0
  125. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_draft7.hpp +198 -0
  126. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_location.hpp +200 -0
  127. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_version.hpp +35 -0
  128. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/subschema.hpp +144 -0
  129. data/lib/jsoncons/jsoncons/include/jsoncons_ext/mergepatch/mergepatch.hpp +103 -0
  130. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/decode_msgpack.hpp +202 -0
  131. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/encode_msgpack.hpp +142 -0
  132. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack.hpp +24 -0
  133. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor.hpp +343 -0
  134. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor2.hpp +259 -0
  135. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_encoder.hpp +753 -0
  136. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_error.hpp +94 -0
  137. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_options.hpp +74 -0
  138. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_parser.hpp +748 -0
  139. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_reader.hpp +116 -0
  140. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_type.hpp +63 -0
  141. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/decode_ubjson.hpp +201 -0
  142. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/encode_ubjson.hpp +142 -0
  143. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson.hpp +23 -0
  144. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_cursor.hpp +307 -0
  145. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_encoder.hpp +502 -0
  146. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_error.hpp +100 -0
  147. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_options.hpp +87 -0
  148. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_parser.hpp +880 -0
  149. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_reader.hpp +92 -0
  150. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_type.hpp +43 -0
  151. data/lib/jsoncons/version.rb +5 -0
  152. data/lib/jsoncons.rb +33 -0
  153. data/test/jsoncons_test.rb +108 -0
  154. data/test/test_helper.rb +7 -0
  155. metadata +268 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 10b43faedc8965c2cd6e67f32d231fdb9c948eac6b8dcf0b947234a4000f35bb
4
+ data.tar.gz: 754df3b74e8c2c122067e200d5511b448cd995efceee344526e9b66cc133b67b
5
+ SHA512:
6
+ metadata.gz: ad1d02c59ec7fd103c2fd708ef42e768a5647a8f111b807546c0ccf95ba4c44aa87daeb56d88e4bfbeb6dc271c20b94779d50e568d1773a9efb7bcbe05502543
7
+ data.tar.gz: 2cde180c82a272da1d585acdf922b255a9d2872983824eb07668a2de448b6858d7436ab4d11af6dbb13469f4c73ac323df42e24880abf227eaf9646786f8a216
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf-rice"
4
+
5
+ # git submodule add git@github.com:danielaparker/jsoncons.git lib/jsoncons/jsoncons
6
+
7
+ # # # git clone --sparse --no-checkout --depth 1 --filter=tree:0 \
8
+ # # # git@github.com:danielaparker/jsoncons.git lib/jsoncons/jsoncons
9
+ # cd lib/jsoncons/jsoncons
10
+ # git sparse-checkout set /include /examples/input
11
+ # git checkout master # v0.169.0
12
+
13
+ gem_root = File.expand_path("../..", __dir__)
14
+ default_include_dir = File.join(gem_root, "lib", "jsoncons", "jsoncons", "include")
15
+
16
+ puts "Default include dir: #{default_include_dir}"
17
+
18
+ # Override with
19
+ # gem install jsoncons -- --with-jsoncons-dir=/path/to/jsoncons
20
+ # or
21
+ # gem install jsoncons -- --with-jsoncons-include=/path/to/jsoncons/include
22
+ # or with rake
23
+ # CONFIGURE_ARGS='--with-jsoncons-dir=/path/to/jsoncons' rake compile && rake install
24
+ # or install
25
+ # gem install pkg/jsoncons-0.1.0.gem -- --with-jsoncons-dir=/path/to/jsoncons
26
+ include_dir, _lib_dir = dir_config("jsoncons", default_include_dir, "")
27
+
28
+ puts "Include dir: #{include_dir}"
29
+
30
+ unless have_header("jsoncons/json.hpp") && have_header("jsoncons_ext/jsonpath/jsonpath.hpp")
31
+ raise <<-MESSAGE
32
+ Can't find "jsoncons/json.hpp" or "jsoncons_ext/jsonpath/jsonpath.hpp"
33
+
34
+ Make sure https://github.com/danielaparker/jsoncons
35
+ is installed on the system.
36
+
37
+ Try passing --with-jsoncons-dir or --with-jsoncons-include
38
+ options to extconf.
39
+ MESSAGE
40
+ end
41
+
42
+ # $CPPFLAGS << " -I./lib/jsoncons/jsoncons/include "
43
+ create_makefile("jsoncons/jsoncons")
@@ -0,0 +1,161 @@
1
+ #include "jsoncons.h"
2
+
3
+ using namespace Rice;
4
+
5
+ typedef /* jsoncons::wojson */ jsoncons::ojson json_class_type;
6
+ // wchar_t is not defined with Rice
7
+ typedef /* std::wstring */ std::string json_string_type;
8
+
9
+ Module rb_mJsoncons;
10
+ Data_Type<json_class_type> rb_cJsoncons_Json;
11
+ Module rb_mJsoncons_JsonPath;
12
+ Data_Type<jsoncons::jsonpath::jsonpath_expression<json_class_type>> rb_cJsoncons_JsonPath_Expression;
13
+ Data_Type<jsoncons::jsonpath::result_options> rb_cJsoncons_JsonPath_ResultOptions;
14
+ Data_Type<jsoncons::json_storage_kind> rb_cJsoncons_StorageKind;
15
+ Data_Type<jsoncons::json_type> rb_cJsoncons_Type;
16
+
17
+ static auto evaluate(const jsoncons::jsonpath::jsonpath_expression<json_class_type> &self,
18
+ const json_class_type &data,
19
+ const std::optional<int> &options = std::nullopt) {
20
+ if (options)
21
+ return self.evaluate(data, static_cast<jsoncons::jsonpath::result_options>(*options));
22
+ else return self.evaluate(data);
23
+ }
24
+
25
+ static auto json_query(const json_class_type &self, const json_string_type &path,
26
+ const std::optional<int> &options = std::nullopt) {
27
+ // throw Rice::create_type_exception<jsoncons::jsonpath::jsonpath_expression<json_class_type>>(SOME_VALUE);
28
+ if (options) // Custom functions and callbacks aren't implemented yet
29
+ return jsoncons::jsonpath::json_query(self, path,
30
+ static_cast<jsoncons::jsonpath::result_options>(*options));
31
+ else return jsoncons::jsonpath::json_query(self, path);
32
+ }
33
+
34
+ extern "C"
35
+ void Init_jsoncons() {
36
+ rb_mJsoncons = define_module("Jsoncons");
37
+ rb_cJsoncons_Json =
38
+ define_class_under<json_class_type>(rb_mJsoncons, "Json")
39
+ .define_constructor(Constructor<json_class_type>());
40
+ rb_mJsoncons_JsonPath = define_module_under(rb_mJsoncons, "JsonPath");
41
+ rb_cJsoncons_JsonPath_Expression =
42
+ define_class_under<jsoncons::jsonpath::jsonpath_expression<json_class_type>>(
43
+ rb_mJsoncons_JsonPath,
44
+ "Expression")
45
+ .define_singleton_function("make", [](const json_string_type &json_query) {
46
+ return jsoncons::jsonpath::make_expression<json_class_type>(json_query);
47
+ })
48
+ .define_method("evaluate", &evaluate,
49
+ Arg("options") = (std::optional<int>) std::nullopt);
50
+
51
+ rb_cJsoncons_JsonPath_ResultOptions =
52
+ define_enum<jsoncons::jsonpath::result_options>("ResultOptions", rb_mJsoncons_JsonPath)
53
+ // Names must be valid for rb_const_set
54
+ .define_value("Value", jsoncons::jsonpath::result_options::value)
55
+ .define_value("NoDups", jsoncons::jsonpath::result_options::nodups)
56
+ .define_value("Sort", jsoncons::jsonpath::result_options::sort)
57
+ .define_value("Path", jsoncons::jsonpath::result_options::path);
58
+ rb_cJsoncons_Type =
59
+ define_enum<jsoncons::json_type>("Type", rb_mJsoncons)
60
+ .define_value("Null", jsoncons::json_type::null_value)
61
+ .define_value("Bool", jsoncons::json_type::bool_value)
62
+ .define_value("Int64", jsoncons::json_type::int64_value)
63
+ .define_value("Uint64", jsoncons::json_type::uint64_value)
64
+ .define_value("Half", jsoncons::json_type::half_value)
65
+ .define_value("Double", jsoncons::json_type::double_value)
66
+ .define_value("String", jsoncons::json_type::string_value)
67
+ .define_value("ByteString", jsoncons::json_type::byte_string_value)
68
+ .define_value("Array", jsoncons::json_type::array_value)
69
+ .define_value("Object", jsoncons::json_type::object_value);
70
+
71
+ rb_cJsoncons_Json.define_singleton_function("parse", [](const json_string_type &source) {
72
+ return json_class_type::parse(source);
73
+ });
74
+ rb_cJsoncons_Json.define_method("to_string", &json_class_type::to_string);
75
+ rb_define_alias(rb_cJsoncons_Json, "to_s", "to_string");
76
+ rb_define_alias(rb_cJsoncons_Json, "inspect", "to_string");
77
+
78
+ // also has_member
79
+ rb_cJsoncons_Json.define_method("contains",
80
+ [](const json_class_type &self, const json_string_type &key) {
81
+ return self.contains(key);
82
+ });
83
+ // rb_cJsoncons_Json.define_method("[]", &key_or_index, Arg("arg").isValue());
84
+
85
+ rb_cJsoncons_Json.define_method("at_key", [](const json_class_type &self,
86
+ const json_string_type &key) {
87
+ return self.at(key);
88
+ });
89
+ rb_cJsoncons_Json.define_method("at_index", [](const json_class_type &self,
90
+ const std::size_t &i) {
91
+ return self.at(i);
92
+ });
93
+ rb_cJsoncons_Json.define_method("query", &json_query,
94
+ Arg("options") = (std::optional<int>) std::nullopt);
95
+
96
+ rb_cJsoncons_Json
97
+ .define_method("size", &json_class_type::size)
98
+ .define_method("empty", &json_class_type::empty)
99
+ .define_method("clear", &json_class_type::clear) // Doesn't work like that # data["arr"].clear
100
+ .define_method("swap", &json_class_type::swap) // Doesn't work like that # data["arr"].swap(other_arr)
101
+ // .define_method("remove", &json_class_type::remove) // erase
102
+ // .define_method("insert", &json_class_type::insert) // add
103
+ // .define_method("insert_or_assign", &json_class_type::insert_or_assign) // set
104
+ // .define_method("push_back", &json_class_type::push_back)
105
+ // .define_method("merge", &json_class_type::merge)
106
+ // .define_method("merge_or_update", &json_class_type::merge_or_update)
107
+ // .define_method("array_value", &json_class_type::array_value)
108
+ // .define_method("object_value", &json_class_type::object_value)
109
+ .define_method("type", &json_class_type::type)
110
+ .define_method("is_null", &json_class_type::is_null)
111
+ // .define_method("count", &json_class_type::count) // Type is not defined with Rice
112
+ .define_method("is_string", &json_class_type::is_string)
113
+ // .define_method("is_string_view", &json_class_type::is_string_view)
114
+ .define_method("is_byte_string", &json_class_type::is_byte_string)
115
+ // .define_method("is_byte_string_view", &json_class_type::is_byte_string_view)
116
+ .define_method("is_bignum", &json_class_type::is_bignum)
117
+ .define_method("is_bool", &json_class_type::is_bool)
118
+ .define_method("is_object", &json_class_type::is_object)
119
+ .define_method("is_array", &json_class_type::is_array)
120
+ .define_method("is_int64", &json_class_type::is_int64)
121
+ .define_method("is_uint64", &json_class_type::is_uint64)
122
+ .define_method("is_half", &json_class_type::is_half)
123
+ .define_method("is_double", &json_class_type::is_double)
124
+ .define_method("is_number", &json_class_type::is_number)
125
+ // .define_method("capacity", &json_class_type::capacity)
126
+ // .define_method("reserve", &json_class_type::reserve)
127
+ // .define_method("resize", &json_class_type::resize) // resize_array
128
+ // .define_method("shrink_to_fit", &json_class_type::shrink_to_fit)
129
+ .define_method("as_bool", &json_class_type::as_bool)
130
+ .define_method("as_double", &json_class_type::as_double);
131
+ // .define_method("as_string", &json_class_type::as_string)
132
+ // .define_method("as_cstring", &json_class_type::as_cstring)
133
+ // .define_method("is_integer", &json_class_type::is_integer)
134
+ // .define_method("is_longlong", &json_class_type::is_longlong) // Deprecated
135
+ // .define_method("is_ulonglong", &json_class_type::is_ulonglong) // Deprecated
136
+ // .define_method("as_longlong", &json_class_type::as_longlong) // Deprecated
137
+ // .define_method("as_ulonglong", &json_class_type::as_ulonglong) // Deprecated
138
+ // .define_method("as_int", &json_class_type::as_int) // Deprecated
139
+ // .define_method("as_uint", &json_class_type::as_uint) // Deprecated
140
+ // .define_method("as_long", &json_class_type::as_long) // Deprecated
141
+ // .define_method("as_ulong", &json_class_type::as_ulong) // Deprecated
142
+ // .define_method("as_integer", &json_class_type::as_integer)
143
+ // .define_method("find", &json_class_type::find)
144
+ // .define_method("at_or_null", &json_class_type::at_or_null) // Type is not defined with Rice
145
+ // .define_method("get_value_or", &json_class_type::get_value_or)
146
+ // .define_method("get_with_default", &json_class_type::get_with_default) // get
147
+ // .define_method("is_datetime", &json_class_type::is_datetime) // Tags
148
+ // .define_method("is_epoch_time", &json_class_type::is_epoch_time) // Tags
149
+ // .define_method("compare", &json_class_type::compare) // "to_json not implemented"
150
+ // rb_define_alias(rb_cJsoncons_Json, "<=>", "compare");
151
+
152
+
153
+ // rb_cJsoncons_Json.define_method("to_a", [](const json_class_type &self) {
154
+ // std::vector<json_class_type> res(self.size());
155
+ // for (int i = 0; i < self.size(); ++i) {
156
+ // res[i] = self[i];
157
+ // }
158
+ // return res;
159
+ // });
160
+ }
161
+
@@ -0,0 +1,10 @@
1
+ #ifndef JSONCONS_H
2
+ #define JSONCONS_H 1
3
+
4
+ #include <rice/rice.hpp>
5
+ #include <rice/stl.hpp>
6
+ #undef isfinite
7
+ #include "jsoncons/json.hpp"
8
+ #include "jsoncons_ext/jsonpath/jsonpath.hpp"
9
+
10
+ #endif /* JSONCONS_H */
data/jsoncons.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jsoncons/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jsoncons"
7
+ spec.version = Jsoncons::VERSION
8
+ spec.authors = ["uvlad7"]
9
+ spec.email = ["uvlad7@gmail.com"]
10
+
11
+ spec.summary = "Ruby wrapper for https://github.com/danielaparker/jsoncons"
12
+ spec.homepage = "https://github.com/uvlad7/ruby-jsoncons"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/uvlad7/ruby-jsoncons"
20
+ spec.metadata["changelog_uri"] = "https://github.com/uvlad7/ruby-jsoncons"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ spec.files = [
24
+ *Dir["lib/jsoncons/jsoncons/include/**/*"].reject { |f| File.directory?(f) },
25
+ "ext/jsoncons/jsoncons.cpp", "ext/jsoncons/jsoncons.h", "jsoncons.gemspec", "lib/jsoncons.rb",
26
+ "lib/jsoncons/version.rb"
27
+ ]
28
+ spec.test_files = [
29
+ *Dir["lib/jsoncons/jsoncons/examples/input/**/*"].reject { |f| File.directory?(f) },
30
+ "test/jsoncons_test.rb", "test/test_helper.rb"
31
+ ]
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+ spec.extensions = ["ext/jsoncons/extconf.rb"]
36
+
37
+ spec.add_dependency "rice", "~> 4.0"
38
+ spec.add_development_dependency "get_process_mem"
39
+ spec.add_development_dependency "pry"
40
+ spec.add_development_dependency "pry-byebug"
41
+
42
+ # For more information and examples about making a new gem, checkout our
43
+ # guide at: https://bundler.io/guides/creating_gem.html
44
+ end
@@ -0,0 +1,13 @@
1
+ {
2
+ "address-book" :
3
+ [
4
+ {
5
+ "name":"Jane Roe",
6
+ "email":"jane.roe@example.com"
7
+ },
8
+ {
9
+ "name":"John",
10
+ "email" : "john.doe@example.com"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "books":
3
+ [
4
+ {
5
+ "category": "fiction",
6
+ "title" : "A Wild Sheep Chase",
7
+ "author" : "Haruki Murakami",
8
+ "price" : 22.72
9
+ },
10
+ {
11
+ "category": "fiction",
12
+ "title" : "The Night Watch",
13
+ "author" : "Sergei Lukyanenko",
14
+ "price" : 23.58
15
+ },
16
+ {
17
+ "category": "fiction",
18
+ "title" : "The Comedians",
19
+ "author" : "Graham Greene",
20
+ "price" : 21.99
21
+ },
22
+ {
23
+ "category": "memoir",
24
+ "title" : "The Night Watch",
25
+ "author" : "Phillips, David Atlee"
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,7 @@
1
+ [
2
+ ["country_code","name"],
3
+ ["ABW","ARUBA"],
4
+ ["ATF","FRENCH SOUTHERN TERRITORIES, D.R. OF"],
5
+ ["VUT","VANUATU"],
6
+ ["WLF","WALLIS & FUTUNA ISLANDS"]
7
+ ]
@@ -0,0 +1,30 @@
1
+ [
2
+ {
3
+ "dept":"sales",
4
+ "employee-name":"Smith, Matthew",
5
+ "employee-no":"00000001",
6
+ "note":"",
7
+ "salary":"150,000.00"
8
+ },
9
+ {
10
+ "dept":"sales",
11
+ "employee-name":"Brown, Sarah",
12
+ "employee-no":"00000002",
13
+ "note":"",
14
+ "salary":"89,000.00"
15
+ },
16
+ {
17
+ "dept":"finance",
18
+ "employee-name":"Oberc, Scott",
19
+ "employee-no":"00000003",
20
+ "salary":"110,000.00"
21
+ },
22
+ {
23
+ "dept":"sales",
24
+ "employee-name":"Scott, Colette",
25
+ "employee-no":"00000004",
26
+ "note":"\"Exemplary\" employee\nDependable, trustworthy",
27
+ "comment":"Team player",
28
+ "salary":"75,000.00"
29
+ }
30
+ ]
@@ -0,0 +1,15 @@
1
+ {
2
+ "definitions": {
3
+ "orNull": {
4
+ "anyOf": [
5
+ {
6
+ "type": "null"
7
+ },
8
+ {
9
+ "$ref": "#"
10
+ }
11
+ ]
12
+ }
13
+ },
14
+ "type": "string"
15
+ }
@@ -0,0 +1,3 @@
1
+ {"a":1,"b":2,"c":3}
2
+ {"a":4,"b":5,"c":6}
3
+ {"a":7,"b":8,"c":9}
@@ -0,0 +1,6 @@
1
+ customer_name,has_coupon,phone_number,zip_code,sales_tax_rate,total_amount
2
+ "John Roe",true,0272561313,01001,0.05,431.65
3
+ "Jane Doe",false,416-272-2561,55416,0.15,480.70
4
+ "Joe Bloggs",false,"4162722561","55416",0.15,300.70
5
+ "John Smith",FALSE,NULL,22313-1450,0.15,300.70
6
+
@@ -0,0 +1,28 @@
1
+ { "store": {
2
+ "book": [
3
+ { "category": "reference",
4
+ "author": "Nigel Rees",
5
+ "title": "Sayings of the Century",
6
+ "price": 8.95
7
+ },
8
+ { "category": "fiction",
9
+ "author": "Evelyn Waugh",
10
+ "title": "Sword of Honour",
11
+ "price": 12.99
12
+ },
13
+ { "category": "fiction",
14
+ "author": "Herman Melville",
15
+ "title": "Moby Dick",
16
+ "isbn": "0-553-21311-3",
17
+ "price": 8.99
18
+ },
19
+ { "category": "fiction",
20
+ "author": "J. R. R. Tolkien",
21
+ "title": "The Lord of the Rings",
22
+ "isbn": "0-395-19395-8",
23
+ "price": 22.99
24
+ }
25
+ ]
26
+ }
27
+ }
28
+
@@ -0,0 +1,6 @@
1
+ project_id, task_name, task_start, task_finish
2
+ 4001,task1,01/01/2003,01/31/2003
3
+ 4001,task2,02/01/2003,02/28/2003
4
+ 4001,task3,03/01/2003,03/31/2003
5
+ 4002,task1,04/01/2003,04/30/2003
6
+ 4002,task2,05/01/2003,
@@ -0,0 +1,38 @@
1
+ // Copyright 2013 Daniel Parker
2
+ // Distributed under the Boost license, Version 1.0.
3
+ // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
+
5
+ // See https://github.com/danielaparker/jsoncons for latest version
6
+
7
+ #ifndef JSONCONS_ALLOCATOR_HOLDER_HPP
8
+ #define JSONCONS_ALLOCATOR_HOLDER_HPP
9
+
10
+ namespace jsoncons {
11
+
12
+ template <class Allocator>
13
+ class allocator_holder
14
+ {
15
+ public:
16
+ using allocator_type = Allocator;
17
+ private:
18
+ allocator_type alloc_;
19
+ public:
20
+ allocator_holder() = default;
21
+ allocator_holder(const allocator_holder&) = default;
22
+ allocator_holder(allocator_holder&&) = default;
23
+ allocator_holder& operator=(const allocator_holder&) = default;
24
+ allocator_holder& operator=(allocator_holder&&) = default;
25
+ allocator_holder(const allocator_type& alloc)
26
+ : alloc_(alloc)
27
+ {}
28
+ ~allocator_holder() = default;
29
+
30
+ allocator_type get_allocator() const
31
+ {
32
+ return alloc_;
33
+ }
34
+ };
35
+
36
+ }
37
+
38
+ #endif