Permalink
Browse files

updatings docs and notes

  • Loading branch information...
1 parent acdb3af commit e0fb1d379c96f79cc87650212b8ab38c88614c88 Peter Ohler committed Feb 26, 2012
Showing with 41 additions and 21 deletions.
  1. +23 −20 README.md
  2. +7 −0 ext/oj/dump.c
  3. +11 −1 notes
View
@@ -39,19 +39,23 @@ time faster than Yajl for parsing and 3 or more times faster writing JSON.
Oj has several dump or serialization modes which control how Objects are
converted to JSON. These modes are set with the :effort option in either the
-dafault options or as one of the options to the dump() method. The :strict
-mode will only allow the 7 basic JSON types to be serialized. Any other Object
-will raise and Exception. In the :lazy mode any Object that is not one of the
-JSON types is replaced by a JSON null. In :interal mode any Object will be
-dumped as a JSON Object with keys that match the Ruby Object's variable names
-without the '@' character. This is the highest performance mode. The :internal
-mode is not found in other JSON gems. The last mode, the :tolerant mode is the
-most tolerant. It will serialize any Object but will check to see if the
-Object implements a to_hash() or to_json() method. If either exists that
-method is used for serializing the Object. The to_hash() is more flexible and
-produces more consistent output so it has a preference over the to_json()
-method. If neither the to_json() or to_hash() methods exist then the Oj
-internal Object variable encoding is used.
+default options or as one of the options to the dump() method.
+
+- :strict mode will only allow the 7 basic JSON types to be serialized. Any other Object
+will raise and Exception.
+
+- :null mode replaces any Object that is not one of the JSON types is replaced by a JSON null.
+
+- :object mode will dump any Object as a JSON Object with keys that match the
+Ruby Object's variable names without the '@' character. This is the highest
+performance mode.
+
+- :compat mode is is the compatible with other systems. It will serialize any
+Object but will check to see if the Object implements a to_hash() or to_json()
+method. If either exists that method is used for serializing the Object. The
+to_hash() is more flexible and produces more consistent output so it has a
+preference over the to_json() method. If neither the to_json() or to_hash()
+methods exist then the Oj internal Object variable encoding is used.
Coming soon: As an Object marshaller with support for circular references.
@@ -63,17 +67,16 @@ Oj is compatible with Ruby 1.8.7, 1.9.2, 1.9.3, JRuby, and RBX.
The following table shows the difference is speeds between several
serialization packages. The tests had to be scaled back due to limitation of
-some of the gems. I finally gave up trying to get JSON to serialize without
-errors with Ruby 1.9.3. It had internal errors on anything other than a simple
-JSON structure. The errors encountered were:
+some of the gems. I finally gave up trying to get JSON Pure to serialize
+without errors with Ruby 1.9.3. It had internal errors on anything other than
+a simple JSON structure. The errors encountered were:
- MessagePack fails to convert Bignum to JSON
-- JSON Pure and Ext fails to serialize any numbers or Objects with the to_json() method
+- JSON Pure fails to serialize any numbers or Objects with the to_json() method
-Options were added to the test/perf_simple.rb test to run the test without
-Object encoding and without Bignums. There is also an option for shallow JSON
-so that JSON Pure and Ext can be compared.
+Options were added to the test/perf_strict.rb test to run the test without
+Object encoding and without Bignums.
None of the packages except Oj were able to serialize Ruby Objects that did
not have a to_json() method or were of the 7 native JSON types.
View
@@ -817,6 +817,13 @@ dump_val(VALUE obj, int depth, Out out) {
default: dump_data_obj(obj, out); break;
}
break;
+ case T_STRUCT: // for Range
+#if (defined T_COMPLEX && defined RCOMPLEX)
+ case T_COMPLEX:
+#endif
+#if (defined T_RATIONAL && defined RRATIONAL)
+ case T_RATIONAL:
+#endif
case T_REGEXP:
// TBD
rb_raise(rb_eNotImpError, "Failed to dump '%s' Object (%02x)\n",
View
12 notes
@@ -6,9 +6,19 @@
- next
- complete all types for dump and load in :object mode
+ case T_STRUCT: // for Range
+ case T_COMPLEX:
+ case T_RATIONAL:
+ case T_REGEXP:
- document format
-
+ - ^? for different types
+ - ^s Symbol
+ - ^o Object
+ - ^c Class
+ - ^t Time
+ - ~ special attr without @ as in Exception mesg and bt
+ - ^# for hash entry
- stream

0 comments on commit e0fb1d3

Please sign in to comment.