Skip to content

Instantly share code, notes, and snippets.

@itayw
Created November 20, 2013 16:35
Show Gist options
  • Save itayw/7566317 to your computer and use it in GitHub Desktop.
Save itayw/7566317 to your computer and use it in GitHub Desktop.
nconf-redis issue with null JSON values
var
nconf = require('nconf');
require('nconf-redis');
var options = {
host:'localhost',
port:80,
method:'GET'
}
var options_bad = {
host:'localhost',
port:80,
securePort:null,
method:'GET'
}
nconf.use('redis');
//save a simple key/value
nconf.set('test', true, function(err) {
if (err)
throw err;
nconf.get('test', function(err, value) {
if (err)
throw err;
if (value)
console.log('Simple key/value set and get fine.');
else
console.log('Failed to set and get simple key/value');
});
});
//save JSON value with no nulls
nconf.set('JSON', options, function(err) {
if (err)
throw err;
nconf.get('JSON', function(err, value) {
if (err)
throw err;
if (value)
console.log('JSON value set and get fine.');
else
console.log('Failed to set and get JSON value')
});
});
//save "BAD" JSON value with no nulls
nconf.set('badJSON', options_bad, function(err) {
if (err)
throw err;
nconf.get('badJSON', function(err, value) {
if (err)
throw err;
if (value)
console.log('bad JSON value set and get fine.');
else
console.log('Failed to set and get bad JSON value')
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment