I am trying to post newly created data to my json database with this call
function sendtovenaarData(url){
$.ajax({
url: "http://localhost:3000/" + url,
type: 'POST',
data:
{
voornaam: $("#voornaam").val(),
achternaam: $("#achternaam").val(),
beroep: $("#beroep").val(),
adres:{
streetAddress: $("#streetAddress").val(),
city: $("#city").val(),
state: $("#state").val(),
zip: $("#zip").val()
},
haardplaats: $("#haardplaats").val(),
favoriete_quote: $("#favoriete_quote").val()
}
}).done(function () {
console.log("data added");
location.reload();
}).fail(function (xhr, message, error) {
console.log(xhr, message, error);
});}
an i want to save it like the top one in the picture but it saves like the bottom one is there anyway around this? image of saved json
I have already tried creating a variable and placing the adres in there but it did not work. Thank you for helping