Robert
Robert

Reputation: 2691

Cosmos db stored procedure filter doesn't work

I have stored procedure in Cosmos db. To the stored procedure I pass json and want to retreive some fields from this json. This is my json:

    [
        {
            "DataStructs": [            
                {
                    "DataStructCells": [
                        {
                            "RowName": "Default",
                            "ColumnName": "Perfect",
                            "CellValue": "0"
                        },
                        {
                            "RowName": "Default",
                            "ColumnName": "percent100",
                            "CellValue": "0"
                        },
                        {
                            "RowName": "Default",
                            "ColumnName": "percent95_99",
                            "CellValue": "0.3"
                        }
                    ],
                    "DataStructName": "GRIDS",
                    "DataStructType": "table",
                    "RowNameIdentifier": "GRID Meaning"
                }
            ]
        },
        "id": "c2665ce6554c4d0ebd715fcc1facf608",
        "pk": "VCT"
    }
]

This line of the code retreive value:

var val = result[0]["DataStructs"][0]["DataStructCells"][0]["CellValue"];

But when I use filter it doesn't work:

var testFilter1 = result[0]["DataStructs"][0]["DataStructCells"].filter(function (s) {
                   return s.columnName === "percent95_99";
               });
console.log(JSON.stringify(testFilter1));

it returns empty array: []

Upvotes: 0

Views: 181

Answers (1)

Noah Stahl
Noah Stahl

Reputation: 7553

JSON is case sensitive. Try changing case in your filter from:

return s.columnName

to

return s.ColumnName

Upvotes: 1

Related Questions