I want to create an object from a Ruby program and store it in an SQL database as a blob. I then want to be able to read this blob directly into a Java program at a later date. I understand that these blobs will probably be incompatible. How can I go about making a Java-readable blob from Ruby?
3 Answers
You can use json (xml, yaml) format to store object as string. And parse it in java.
4 Comments
providence
How fast would this be for exceptionally large objects, though? Say ~100mb.
Mikita Belahlazau
Don't know, try it. But I don't think there is good way to serialize native ruby object and deserialize it as java object. Even if it's possible, I doubt it would be fast.
zengr
It wouldn't be as fast as it would be without serializing/Deserializing. The best way is to benchmark it and see how it works for you.
providence
OK, thanks. Accepting this answer as, although the other one provides helpful links, this one also answered my follow-up.
- Serialize ruby object to YAML (or JSON, XML etc)
- Save it in the DB
- Deserialize it from YAML to Java object