發行
我想打電話給JSON.stringify走過時,我想在字符串中包含的字段。我想包括的一個領域是一個對象。 JSON.stringify方法不包含對象的任何字段,因爲我會預期的。Json.stringify特定字段,其中字段一個是對象
這是我的大對象的一小部分;
var person = {
name: "John Doe",
Address: { Line1: "100 north main", City: "Des Moines" },
Phone: "555-5555"
}
這裏是字符串化方法調用
console.log(JSON.stringify(person,["name","Address"]));
這是效果
"{\"name\":\"John Doe\",\"Address\":{}}"
這裏是一個js斌我創建 - http://jsbin.com/UYOVufa/1/edit?html,console。
我總是可以將人物串起來。地址並將它與另一個字符串結合起來,但感覺像是過度殺傷。
我錯過了什麼?
謝謝,
有趣的是,感謝您的代碼。 – RDotLee