Discussions

Ask a Question
Back to All

Complex JSON source

Given this JSON:
{
"data": {
"noteFilterViewId": 131,
"name": "MikeCProvider",
"groups": [
{
"noteFilterViewGroupId": 1396,
"noteFilterDiscreteDataType": {
"noteFilterDiscreteDataTypeId": 14,
"description": "Templates",
"sortIndex": 1
},
"isShown": true,
"isExpanded": true,
"sortIndex": 1
},
{
"noteFilterViewGroupId": 1397,
"noteFilterDiscreteDataType": {
"noteFilterDiscreteDataTypeId": 15,
"description": "Discrete Text",
"sortIndex": 2
},
"isShown": true,
"isExpanded": true,
"sortIndex": 2
},
{
"noteFilterViewGroupId": 1398,
"noteFilterDiscreteDataType": {
"noteFilterDiscreteDataTypeId": 12,
"description": "General",
"sortIndex": 3
},
"isShown": true,
"isExpanded": true,
"sortIndex": 3
},
{
"noteFilterViewGroupId": 1399,
"noteFilterDiscreteDataType": {
"noteFilterDiscreteDataTypeId": 13,
"description": "Chief Complaint",
"sortIndex": 4
},
"isShown": true,
"isExpanded": true,
"sortIndex": 4,
"items": [
{
"noteFilterViewGroupItemId": 5983,
"currentShownItemNoteFilterHistoryId": 2967,
"filter": {
"noteFilterId": 4670,
"name": "This Visit 1"
},
"template": null,
"discreteTextKey": null,
"isShown": true,
"sortIndex": 0
},
{
"noteFilterViewGroupItemId": 5976,
"currentShownItemNoteFilterHistoryId": 517,
"filter": {
"noteFilterId": 1222,
"name": "Chief Complaint"
},
"template": null,
"discreteTextKey": null,
"isShown": true,
"sortIndex": 1
},
{
"noteFilterViewGroupItemId": 5977,
"currentShownItemNoteFilterHistoryId": 2985,
"filter": {
"noteFilterId": 4620,
"name": "Chief FIlter"
},
"template": null,
"discreteTextKey": null,
"isShown": true,
"sortIndex": 2
},
{
"noteFilterViewGroupItemId": 5978,
"currentShownItemNoteFilterHistoryId": 2887,
"filter": {
"noteFilterId": 4621,
"name": "CHief Jeff"
},
"template": null,
"discreteTextKey": null,
"isShown": true,
"sortIndex": 3
}
]
}
]
},
"errors": [],
"success": true,
"validations": []
}

I want to select the item id, the filter name, and the sort index for group with data type 13. I've gotten this far (where the variable "view" is assigned the above JSON):
var group = new jinqJs()
.from(view.data.groups)
.where( function(row) { return (row.noteFilterDiscreteDataType.noteFilterDiscreteDataTypeId == 13); } )
.select()[0];

$scope.data = new jinqJs()
  .from(group.items)
  .select('noteFilterViewGroupItemId', 'filter.name', 'sortIndex');

That gives me the right noteFilterViewGroupItemId and sortIndex, but filter.name is not working. If I change it to 'filter' it includes the whole filter object in the result.

Here's my Plunk: http://plnkr.co/edit/sj3ffCRsERoKnj8qlYjG?p=preview