I have bin working on this for hours now.
In php I would have done this
$i = 0;
foreach ($input as $obj) {
$array[$i]['subject'] = $obj;
$i++;
}
$json = json_encode($array);
In Jquery i have this, where I have multiple form inputs with the same name, and I need to create a json input to submit safely in the form.
var i = 0;
$('.tekstforms').each(function(i, obj) {
items[i]['emne'] = $(this).closest(".tekstforms").find("[name='emne']").val();
i++;
});
alert(JSON.stringify(items));
But that's not working