UPDATE: I've tried something similar to this, but it's not working. I believe there lies the issue
var stringifyObj = JSON.stringify({
"addressAddressId":$('#address').val(){
"cityId:"$('#city').val(){
"postalCode":$('#postalCode').val()
}
}
});
*When I create a test client in Netbeans, the JSON structure (GET/JSON) looks like this. How can I implement this using JavaScript and the Stringify function? *
"addressAddressId": {
"addressId": 1,
"address": "Railway Street 2",
"address2": null,
"district": null,
"postalCode": "20360",
"phone": null,
"coordinates": null,
"latitude": null,
"longitude": null,
"directions": null,
"description": null,
"addrZipCityCountry": null,
"lastUpdated": 1361754860000,
"cityId": {
"cityId": 1,
"city": "",
"lastUpdate": 1361754850000,
"countryCountryId": {
"countryId": 1,
"country": "Sweden",
"lastUpdate": 1361754837000
}
}
},
INQUIRY
- What is the correct syntax for using JSON.stringify with custom object types such as City-object within Address-object?
- Do I need to include every field in the JSON if I'm not using @JsonIgnoreProperties({""})? I only require address, city, and postal code. Address is of type Address with a string address field on the server side, while City is of type City containing a string field for city name, etc.