我有一个嵌套的json.我想将其作为表单输入值发布.
但是,似乎jquery将“Object object”字符串放入值中.
传递字符串并转换为我需要的本机形式似乎比处理json更容易,因为一旦生成它就不需要改变任何东西.
转换json的最简单方法是什么?
var json = { "firstName": "John","lastName": "Smith","age": 25,"address": { "streetAddress": "21 2nd Street","city": "New York","state": "NY","postalCode": "10021" },"phoneNumber": [ { "type": "home","number": "212 555-1234" },{ "type": "fax","number": "646 555-4567" } ],"newSubscription": false,"companyName": null };
成为字符串形式?
var json = '{ "firstName": "John","companyName": null }'
以下没有做我需要的:
Json.stringify()