I am facing a problem will reading a json string containing nested arrays.
{
"invoiceSet": {
"lines": [
{
"line": "Business Partner had two or more interactions in the last 30 days",
"togState": "true",
"links": [
{
"linktxt": "Interaction History",
"linkid": "IRHIST"
}
]
},
{
"line": "Open CRC Complaints Exist",
"togState": "false",
"links": [
{
"linktxt": "Interaction History",
"linkid": "IRHIST"
}
]
},
{
"line": "Open Complaints Exist",
"togState": "true",
"links": [
{
"linktxt": "Interaction History",
"linkid": "IRHIST"
}
]
},
{
"line": "Business Partner is a landlord",
"togState": "false",
"links": []
},
{
"line": "Remotes Business Partner",
"togState": "true",
"links": [
{
"linktxt": "Interaction History",
"linkid": "IRHIST"
}
]
},
{
"line": "Recent move has occurred in the last 60 days",
"togState": "false",
"links": []
}
]
}
}
I am using ajax call to get this json in a string
var setJsonText = jQuery.ajax({ url: ajxUrl,
cache: false,
async: false,
type:"POST",
dataType: "html" }).responseText;
var sets = jQuery.parseJSON( setJsonText );
viewModel.invLines(sets.invoiceSet.lines)
And my viewmodel
var viewModel = {
invLines: ko.observableArray([]),
};
HTML
<table width="100%" >
<tbody data-bind="foreach: invLines" style="width:100%">
<tr>
<td data-bind="text: line"></td>
<td>
<ul data-bind="foreach:links">
<li>
<a><span data-bind="text:linktxt"></span></a>
</li>
</ul>
</tbody>
</table>
The line are getting correctly printed but problem in coming on corresponding links. Please let me know what m i doing wrong.
Thanks, Anshul Kaistha