node-zkplus icon indicating copy to clipboard operation
node-zkplus copied to clipboard

Feature: accept all data formats, not just JSON

Open vvo opened this issue 12 years ago • 1 comments

Sorry to spam you with issues but.

Why not accept all data formats in zkplus?

One thing that blocked me was that I wanted to store some text into /a/node and it failed because I had to wrap it with JSON.

Default data format should be to store object as they are.

If you want to use JSON you should be able to do like nconf do:

The file store is also extensible for multiple file formats, defaulting to JSON. To use a custom format, simply pass a format object to the .use() method. This object must have .parse() and .stringify() methods just like the native JSON object.

I don't think we should default to JSON even if it's the current way of operating of zkplus. It's not obvious that node-zkplus is working with only-json as when you're using node-zookeeper you just store what you want in the format you want.

var zk = zkplus({
                 servers: [],
                 format: {
                     parse: JSON.parse,
                     stringify: JSON.stringify
                   }
                });

What do you think?

I can do this, but then we should bump to a major version.

vvo avatar Sep 29 '12 09:09 vvo

Hi Vincent,

That seems like a good idea to me - I really only setup JSON b/c that's what I needed at the time, and I honestly I didn't expect a large install base here :). So, I'm fine with breaking that pattern to be more general.

m

On Sat, Sep 29, 2012 at 2:19 AM, Vincent Voyer [email protected]:

Sorry to spam you with issues but.

Why not accept all data formats in zkplus?

One thing that blocked me was that I wanted to store some text into /a/node and it failed because I had to wrap it with JSON.

Default data format should be to store object as they are.

If you want to use JSON you should be able to do like nconf do:

The file store is also extensible for multiple file formats, defaulting to JSON. To use a custom format, simply pass a format object to the .use() method. This object must have .parse() and .stringify() methods just like the native JSON object.

I don't think we should default to JSON even if it's the current way of operating of zkplus. It's not obvious that node-zkplus is working with only-json as when you're using node-zookeeper you just store what you want in the format you want.

var zk = zkplus({ servers: [], format: { parse: JSON.parse, stringify: JSON.stringify } }

What do you think?

I can do this, but then we should bump to a major version.

— Reply to this email directly or view it on GitHubhttps://github.com/mcavage/node-zkplus/issues/18.

mcavage avatar Oct 01 '12 13:10 mcavage