I have on HTML form. I need to convert that form fields into JSON object when I use jQuery "Stringify" it will give name of the object as name and value of the object as value.
function onSubmit( form ){
var data = JSON.stringify( $(form).serializeArray() );
alert(data);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form class="box" onsubmit='return onSubmit(this)'>
<input type="text" name="tax_val" class="P_tax_val" size="10" placeholder="Val" value="" required />
<input type="submit" name="SUBMIT" />
</form>
The above image have name as tax_val and value is 2100 but I need a object as [{"tax_val":"2100"}]