My jQuery is a bit rusty and cant remember how to generate json objects. Im trying to create the below json from my serialize method but it doesnt fill the tags with anything else then two values?
function serializeObject() {
var o = {};
o["CompanyTemplateId"] = CompanyTemplateId;
o["Tags"] = [];
$("[id^=DQTag]").each(function () {
o["Tags"].push({'TagKey': $(this).id, 'TagValue': $(this).value});
});
return o;
};
What I would like it to look like:
{"CompanyTemplateId": "1",
"Tags":[
{"TagKey":"news1","TagValue":"This is a news item from tagValue."},{"TagKey":"news2","TagValue":"Second value"}
]
}
The result i get is :
{"CompanyTemplateId":"1","Tags":[{},{}]}.
The number of objects in the Tags are correct but why isnt there any key/value pairs?