Problem with JSon
I'm not getting concatenate the variables to make an acceptable result for开发者_StackOverflow社区 json, can someone give me an idea of the correct form of concatenation?
I'm doing this:
date: '{"sUserName": "' + nomeUser'","' + + '" sPassword ":"' + password +'"}',
and the result is as follows:
{"sUserName": "a", "" sPassword ":" a "}
Replace:
'{"sUserName": "' + nomeUser'","' + + '" sPassword ":"' + password +'"}'
with
'{"sUserName": "' + nomeUser + '","' + 'sPassword":"' + password +'"}'
You have an extra '+' and an extra ". And here's a simple way to avoid this in the future:
var obj = {}; obj.sPassword = 'test'; obj.sUserName = 'p'; JSON.stringify(obj)
精彩评论