2
I am receiving an object as a parameter, for example: "4,5", from a function, but I need to exchange the comma for a point. Qnd I do this, the object is changed to string, so I need to return this string to object again. qnd dou u, Alert no typeof(obj), I get a string.
var teste = JSON.stringify(editableObj.innerHTML);
teste = teste.replace(/\,/g, '.');
var obj = JSON.parse(teste);
alert(typeof(obj));
I don’t understand what JSON has to do with this, nor what its real problem is. It can do a [mcve]?
– Maniero
i receive an object from a function, then convert it to string using JSON.stringify, to be able to swap the comma for a point, so I need to convert back to object after exchanging the comma for a point.
– Sidclay Ataíde
Just with this I don’t see how I can help you. Maybe this isn’t even the solution. Can you make a [mcve]?
– Maniero
Imagine the (Editable.innerHTML), as the q I get from the web form, it comes in object format, and to be clearer the object is a value like: "4,6". so I can update my database, if the value is comma, it doesn’t work. hence I need to exchange the comma for a point. imagine q in the second line of the code, I now have a value= 4.6 and not 4.6 (with comma after user replace it). then this value 4.6 qnd I use Alert (typeof(obg)), I get a string and not an object as I would need to convert from bellows to follow my code and update in the database correctly.
– Sidclay Ataíde
Imagining is more complicated, a [mcve] is much easier.
– Maniero
unfortunately for you the code is difficult but for me it is well explained, only unsolved.
– Sidclay Ataíde