-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Current behavior is in spirit of automatic type detection with optional quotes. Features exactly the same behavior as uses YAML:
(note: comma in uson can be replaced by whitespace, but for comparison, I did not do it)
var uson = require('./');
var yaml = require('js-yaml');
var assert = require('assert');
var str = '[ true, false, null, 1, 12.34, string, undefined, NaN, Number, "false" ]';
console.log(JSON.stringify(uson.parse(str, 'json')));
console.log(JSON.stringify(yaml.load(str)));
console.log(assert.deepEqual(uson.parse(str, 'json'), yaml.load(str)) ? false : true);Returns:
[ true, false, null, 1, 12.34, "string", "undefined", "NaN", "Number", "false" ]
[ true, false, null, 1, 12.34, "string", "undefined", "NaN", "Number", "false" ]
trueBut as pointed ZyklusDieWelt on reddit (source), it's ambiguous. You have to memorize that undefined gets set to a string and null to null.
Does anyone have a idea how to solve this problem? eventually, its a big problem for you?
Example of YAML shows that it works relatively good without problems, and if we want to save characters for typing, its a reasonable compromise for me.