mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
handle empty string keyed objects
This commit is contained in:
parent
fd5e6185ac
commit
af5da577cd
@ -76,7 +76,7 @@ yson.parseAsync = function(text, done, revive, M){
|
||||
if(ctx.at instanceof Array){
|
||||
ctx.at.push(ctx.at = {});
|
||||
} else
|
||||
if(tmp = ctx.s){
|
||||
if(u !== (tmp = ctx.s)){
|
||||
ctx.at[tmp] = ctx.at = {};
|
||||
}
|
||||
ctx.a = u;
|
||||
@ -97,7 +97,7 @@ yson.parseAsync = function(text, done, revive, M){
|
||||
ctx.at = ctx.up.pop();
|
||||
break;
|
||||
case '[':
|
||||
if(tmp = ctx.s){
|
||||
if(u !== (tmp = ctx.s)){
|
||||
ctx.up.push(ctx.at);
|
||||
ctx.at[tmp] = ctx.at = [];
|
||||
} else
|
||||
@ -125,6 +125,7 @@ yson.parseAsync = function(text, done, revive, M){
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.s = u;
|
||||
ctx.i = i;
|
||||
ctx.w = w;
|
||||
if(ctx.end){
|
||||
@ -157,8 +158,7 @@ function value(s){
|
||||
}
|
||||
|
||||
yson.stringifyAsync = function(data, done, replacer, space, ctx){
|
||||
//try{done(u, JSON.stringify(data, replacer, space))}catch(e){console.log('%%',e);done(e)}return;
|
||||
//console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
|
||||
//try{done(u, JSON.stringify(data, replacer, space))}catch(e){done(e)}return;
|
||||
ctx = ctx || {};
|
||||
ctx.text = ctx.text || "";
|
||||
ctx.up = [ctx.at = {d: data}];
|
||||
|
@ -81,7 +81,14 @@ describe('Gun', function(){
|
||||
JSON.stringifyAsync(obj, function(err, text){
|
||||
JSON.parseAsync(text, function(err, data){
|
||||
expect(data).to.be.eql([{x:"test",a:true,c:3,y:"yes","get":{"#":"chat"},foo:[1,null,null,'go'],blah:9}]);
|
||||
done();
|
||||
|
||||
var obj = {a: [], b: [""], c: ["", 1], d: [1, ""], e: {"":[]}, "a\"b": {0: 1}, wow: {'': {cool: 1}}};obj.lol = {0: {sweet: 9}};obj.wat = {"": 'cool'};obj.oh = {phew: {}, "": {}};
|
||||
JSON.stringifyAsync(obj, function(err, text2){
|
||||
JSON.parseAsync(text2, function(err, data){
|
||||
expect(data).to.be.eql(obj);
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user