Thank for your speedy response. I try to be a little more clearer this time, but i thought maybe you guys could have guessed the cause of it by just mentioning some stray quotes.
Anyway this is my code:
Code: Select all
var obj = {k1 :'some val 1', k2: 'some val 2'}
var str = JSON.stringify(obj);
console.log("=|" + str + "|=");
var uv = new SFS2X.Entities.Variables.SFSUserVariable("jsonStr", str);
sfs.send(new SFS2X.Requests.System.SetUserVariablesRequest([uv]));
sfs.addEventListener(SFS2X.SFSEvent.USER_VARIABLES_UPDATE, function(){
console.log( " -|" +$rootScope.sfs.mySelf.getVariable("jsonStr").value+"|-" );
}, this);
The output is below... i added -| and |- to make the boundaries clear.
Code: Select all
=|{"k1":"some val 1","k2":"some val 2"}|=
-|"{"k1":"some val 1","k2":"some val 2"}"|-
now with the same code as before but added whitespace to str:
Code: Select all
var str = " " + JSON.stringify(obj) + " ";
output as expected:
Code: Select all
=| {"k1":"some val 1","k2":"some val 2"} |=
-| {"k1":"some val 1","k2":"some val 2"} |-