Comments (1)
Oj has been around for a long time. The first mode it had was the object mode. This allowed objects to be dumped and loaded. It was and still is the default mode mostly due to not wanting to break the code of early adopters. The page that describes the format used for the object mode is: https://github.com/ohler55/oj/blob/develop/pages/Encoding.md. This mode is supported by the Oj.load and Oj.parse functions which are also part of the original behavior.
Fast forward to the newer Oj::Parser which was developed to provide not only better performance but more importantly a means of isolating on set of parse configurations from all others so as to avoid issues with conflicting options as the default and specific calls. Since the lack of isolation revolved around the use of Rails and the JSON gem I did not implement a delegate for the original object mode.
With that history in mind, calling Oj.dump without changing the mode will use object mode for encoding. The result can be used to reconstitute objects with the Oj.xxx calls but not with the Oj::Parser. As you discovered the other option is to use the create_id. (You did uncover a bug there. The calculation for the limit of the create_id length is off. My tests only used a one character create_id so I didn't catch it.)
from oj.
Related Issues (20)
- Does `max_nesting` work? HOT 14
- Getting `TypeError: wrong argument type nil (expected Class)` instead of expected `Oj::ParseError`
- oj_parse_xml_time parses incorrectly unless there are exactly 9 fractional digits HOT 1
- Optimize JSON for pub sub transmission? HOT 1
- Parser options documentation formatting error HOT 3
- Migrating strict mode options to the new usual parser HOT 4
- BigDecimal 3.1 dependency brings excessive memory usage HOT 8
- Rejecting invalid UTF-8 without opting in to XSS character escaping HOT 2
- "Optimized" implementations of ActiveSupport methods not used with `render json: ...`
- Oj.optimize_rails breaks JSON.load - creates BigDecimal instead of Float HOT 3
- How do you get Oj to dump a big decimal as a number not in scientific notation? HOT 9
- Behavior with Oj.default_options of create_additions: true HOT 2
- Issues with DelegateClass. HOT 11
- `Oj::Parser#load` fails on buffered input HOT 9
- problem with serializing strong params (3.11.0+) HOT 5
- `Oj::Parser` should support loading of multiple JSON elements HOT 8
- Error when dumping Hash with `Time` value and numeric `:indent` option HOT 7
- #as_json ignored on Rails 7.2.0 HOT 4
- Using the :space option in conjunction with the :indent option fails to actually indent in :compat mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oj.