我有一个JSON字符串(?),我从$.ajax()返回并将其命名为“数据”.一些值是空的,我需要添加一些键值并将其发送回我的
PHP脚本.
我通过data.keyName访问现有的值.如何在“数据”中添加或更改某些键的值?
这就是“数据”的样子.
{"ID":"48","userID":"0","address":"750 North High Street","city":"Columbus","state":"OH","zip":"43215","lat":"39.977673","lng":"-83.003357","busNumber":"55","isClaimed":"N","whereFound":"","busNum":"","email":"","fname":"","lname":"","comments":""}
解决方法
一旦解码了JSON,结果就是一个JavaScript对象.只要像任何其他对象一样操纵它.例如:
data.busNum = 12345; ...