I want to transform values from form's fields into JSON object, but I want it to be in a specific format. Something like this:
{name: "John", surname: "Smith"}
Is there an easy way to do it? I don't want to build each field manually since there might be a lot of them, and I don't want to do it this way
var data = JSON.stringify($("#newUserForm").serializeArray());
because in this case, JSON will look something like this:
[{"name":"name","value":"John"},{"name":"surname","value":"Smith"}]
Maybe there are some jQuery plugins or other tricks to do it in one line of code?