Almost a fix!
Replace the Uint8Array using E.toString()
do the JSON
Replace the strings using E.toUint8Array()
//jsontest1.js
//21aug2016
function A(){
this.A=1;
this.B= new Uint8Array(16);
this.s= new Uint8Array(16);
}
A.prototype.setup=function(){
var i;
for(i=0;i<16;i++)this.B[i]=i;
};
function B(){
this.B= 2; // new Uint8Array(16);
this.s= 2; //new Uint8Array(16);
this.A=1;
}
var a=new A();
a.setup();
console.log(a);
//Almost a fix
a.B=E.toString(a.B);
a.s=E.toString(a.s);
console.log(a);
//
var e=JSON.stringify(a);
console.log(e);
var f=JSON.parse(e);
console.log("f= ",f);
//Almost a fix
f.B=E.toUint8Array(f.B);
f.s=E.toUint8Array(f.s);
console.log("f= ",f);
console.log(" ");
var b=new B();
console.log(b);
var e1=JSON.stringify(b);
console.log(e1);
var f1=JSON.parse(e1);
console.log("f1= ",f1);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Almost a fix!
Replace the Uint8Array using E.toString()
do the JSON
Replace the strings using E.toUint8Array()
The output:
Problem the 7 gets changed to 97
2 Attachments