mirror of
https://github.com/amark/gun.git
synced 2025-07-02 02:42:34 +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){
|
if(ctx.at instanceof Array){
|
||||||
ctx.at.push(ctx.at = {});
|
ctx.at.push(ctx.at = {});
|
||||||
} else
|
} else
|
||||||
if(tmp = ctx.s){
|
if(u !== (tmp = ctx.s)){
|
||||||
ctx.at[tmp] = ctx.at = {};
|
ctx.at[tmp] = ctx.at = {};
|
||||||
}
|
}
|
||||||
ctx.a = u;
|
ctx.a = u;
|
||||||
@ -97,7 +97,7 @@ yson.parseAsync = function(text, done, revive, M){
|
|||||||
ctx.at = ctx.up.pop();
|
ctx.at = ctx.up.pop();
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
if(tmp = ctx.s){
|
if(u !== (tmp = ctx.s)){
|
||||||
ctx.up.push(ctx.at);
|
ctx.up.push(ctx.at);
|
||||||
ctx.at[tmp] = ctx.at = [];
|
ctx.at[tmp] = ctx.at = [];
|
||||||
} else
|
} else
|
||||||
@ -125,6 +125,7 @@ yson.parseAsync = function(text, done, revive, M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ctx.s = u;
|
||||||
ctx.i = i;
|
ctx.i = i;
|
||||||
ctx.w = w;
|
ctx.w = w;
|
||||||
if(ctx.end){
|
if(ctx.end){
|
||||||
@ -157,8 +158,7 @@ function value(s){
|
|||||||
}
|
}
|
||||||
|
|
||||||
yson.stringifyAsync = function(data, done, replacer, space, ctx){
|
yson.stringifyAsync = function(data, done, replacer, space, ctx){
|
||||||
//try{done(u, JSON.stringify(data, replacer, space))}catch(e){console.log('%%',e);done(e)}return;
|
//try{done(u, JSON.stringify(data, replacer, space))}catch(e){done(e)}return;
|
||||||
//console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
|
|
||||||
ctx = ctx || {};
|
ctx = ctx || {};
|
||||||
ctx.text = ctx.text || "";
|
ctx.text = ctx.text || "";
|
||||||
ctx.up = [ctx.at = {d: data}];
|
ctx.up = [ctx.at = {d: data}];
|
||||||
|
@ -81,7 +81,14 @@ describe('Gun', function(){
|
|||||||
JSON.stringifyAsync(obj, function(err, text){
|
JSON.stringifyAsync(obj, function(err, text){
|
||||||
JSON.parseAsync(text, function(err, data){
|
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}]);
|
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